home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume90 / libraris / ezlib / part01 next >
Encoding:
Internet Message Format  |  1990-10-10  |  74.6 KB

  1. Path: abcfd20.larc.nasa.gov!amiga-request
  2. From: amiga-request@abcfd20.larc.nasa.gov (Amiga Sources/Binaries Moderator)
  3. Subject: v90i269: ezlib - a library of functions; make programming easier, Part01/02
  4. Reply-To: nick@chopin.uucp (Dominic Giampaolo)
  5. Newsgroups: comp.sources.amiga
  6. Message-ID: <comp.sources.amiga:v90i269@abcfd20.larc.nasa.gov>
  7. Date: 10 Oct 90 00:59:54 GMT
  8. Approved: tadguy@uunet.UU.NET (Tad Guy)
  9. X-Mail-Submissions-To: amiga@uunet.uu.net
  10. X-Post-Discussions-To: comp.sys.amiga
  11.  
  12. Submitted-by: nick@chopin.uucp (Dominic Giampaolo)
  13. Posting-number: Volume 90, Issue 269
  14. Archive-name: libraries/ezlib/part01
  15.  
  16. [ uuencoded library and executable enclosed  ...tad ]
  17.  
  18. Here is a link time library I have written.  This library makes
  19. writing programs that access Amiga specific features somewhat easier.
  20. There are readme files that go into more detail in the archive.
  21. Essentially the library provides abstract access to the creation of
  22. screens, window, and boolean gadgets (and some other things) - i.e.
  23. you don't have to worry about all the gory details any more.
  24.  
  25. #!/bin/sh
  26. # This is a shell archive.  Remove anything before this line, then unpack
  27. # it by saving it into a file and typing "sh file".  To overwrite existing
  28. # files, type "sh file -c".  You can also feed this as standard input via
  29. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  30. # will see the following message at the end:
  31. #        "End of archive 1 (of 2)."
  32. # Contents:  README demo_src demo_src/frac demo_src/frac/frac.c
  33. #   demo_src/frac/makefile demo_src/sin demo_src/sin/makefile
  34. #   demo_src/sin/sin.c doc doc/closelibs.doc doc/create_boolgadget.doc
  35. #   doc/createwindow.doc doc/defines.doc doc/free_bitmap.doc
  36. #   doc/getbitmap.doc doc/getfont.doc doc/getstring.doc doc/getyn.doc
  37. #   doc/killgadget.doc doc/killscreen.doc doc/killwindow.doc
  38. #   doc/laced_wb.doc doc/makeboolgadget.doc doc/makescreen.doc
  39. #   doc/makewindow.doc doc/openlibs.doc ezlib.h src src/ezlib.h
  40. #   src/gadg.c src/gadget.c src/getfont.c src/getyn.c src/include
  41. #   src/include/includes.h src/makefile src/openlibs.c src/window.c
  42. # Wrapped by tadguy@abcfd20 on Tue Oct  9 20:59:50 1990
  43. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  44. if test -f 'README' -a "${1}" != "-c" ; then 
  45.   echo shar: Will not clobber existing file \"'README'\"
  46. else
  47. echo shar: Extracting \"'README'\" \(5223 characters\)
  48. sed "s/^X//" >'README' <<'END_OF_FILE'
  49. X                 Ez Lib
  50. X         A link time library to make life easy
  51. X         -------------------------------------
  52. X
  53. X    Howdy.  You have just gotten your greedy little hands on a library
  54. Xcalled Ez.lib.    Ez.lib is a link time library which provides numerous calls
  55. Xto access many Intuition features without the normal hassle.  There are
  56. Xsingle line calls to open any type of screen, window, or boolean gadget.
  57. X
  58. X    This library is my effort at making the Amiga a little bit less of a
  59. Xbear to program.  You can now do something like this:
  60. X
  61. X        struct Screen *screen;
  62. X
  63. X        screen = makescreen(HIRES|LACE, 4); /* 640x400x16 color */
  64. X        if (screen == NULL)
  65. X          error_no_screen();
  66. X
  67. X    As you can see from the above code, you will save yourself HOURS of
  68. Xtime with a single function call.  No more hassling around worrying about
  69. XBitMap structures etc....  The makescreen() call will even check to make
  70. Xsure that Graphics.library and Intuition.library are opened.  Working with
  71. Xscreens, windows, and boolean gadgets now becomes trivial.
  72. X
  73. X    In addition there are two "widgets" in the library.  The first widget
  74. Xis getyn().  It will simply return true or false depending on how the user
  75. Xclicked the AutoRequest().  NOTE: this function was taken from M. Dillon's
  76. XDME, however I did enhance it somewhat.
  77. X    The other "widget", getstring() will pop open a small window to get a
  78. Xstring of input from the user.    It is about as difficult to use as fgets()
  79. Xor similar - making it easy to create Intuitionized programs.
  80. X
  81. X    For the more hacker types there are a few lower level functions
  82. Xwhich you can call if you wish.  These provide access to properly allocated
  83. Xand filled in BitMaps, Gadgets, and other things.
  84. X
  85. X
  86. X
  87. X
  88. X               Installing and Using Ez.lib
  89. X               ---------------------------
  90. X
  91. X    What do you have to do to use all these nifty and wonderful things?
  92. X
  93. X    Not much.  The included library is for Manx 3.6.  If you have Manx 5.0
  94. Xyou will just have to recompile the modules and use LB to make the library.
  95. XYou can find out more about this by looking at the makefile in the SRC
  96. Xdirectory.
  97. X
  98. X    If you have Lattice, you will have to recompile the modules and then
  99. Xuse whatever tool is provided with Lattice to make a link time library.  I
  100. Xdon't have Lattice so I can't help you too much.  Basically all there is in
  101. Xthe SRC directory is a bunch of individual source modules which need to be
  102. Xcompiled.  Granted the code isn't ANSI C, but it should compile without too
  103. Xmany warnings (I hope ;^)
  104. X
  105. X    After you have the correct version of the library, you simply need to
  106. Xput it where your compiler will find it.  Same thing for the header file.
  107. XYou can just put these wherever your setup looks for them.
  108. X
  109. X    Then, when you write a program that uses Ez.lib, you just
  110. X
  111. X         #include <ezlib.h>
  112. X
  113. Xat the beginning of your program.  When you get to the linking stage,
  114. Xsimply link with ez.lib (e.g. "ln -o demo demo.o -lez -lc") and you are
  115. Xdone.  That's it, no more no less.
  116. X
  117. X
  118. X
  119. X
  120. X            Other things of interest
  121. X            ------------------------
  122. X
  123. X    The full docs for each of the functions in Ez.lib are in the DOC
  124. Xdirectory.  Poke around there for more info.
  125. X
  126. X    The SRC directory just contains the individual files that provide the
  127. Xfunctionality.    You can sniff through here if you don't trust my coding or
  128. Xto see if I did something wrong (hey, if I did I'd like to hear about it,
  129. Xas I certainly don't want trashy code floating around with my name on it :)
  130. X
  131. X    The demo that is in the root level is just a simple demo which
  132. Xexercises each of the features in Ez.lib.  As you can see it is less than
  133. X9K and does a fair amount.  BTW, it looks for a font.  If you don't have it
  134. Xit's no big deal, but just so you know.
  135. X
  136. X    The DEMOS directory contains a few programs that show how to use the
  137. Xlibrary.  They are all very simple, purposely, so that you can see how the
  138. Xlibrary is used.
  139. X
  140. X
  141. X
  142. X                Final Notes
  143. X                -----------
  144. X
  145. X    At the moment the gadget creation facilities are somewhat plain.  They
  146. Xjust create simple box affairs.  I'm looking into changing this to a more
  147. X3-D'ish look.  Don't worry though as the changes would be transparent to
  148. Xyou - they would just require a re-compile.
  149. X
  150. X    I'm going to continue to add functionality to this library as needed.
  151. XI'd like access to string gadgets and ideally prop gadgets too (but I
  152. Xunderstand this is much easier in 2.0, so I may not bother).  I'm probably
  153. Xgoing to add some Rexx code that I have written (to send/receive rexx
  154. Xmessages in an abstract way - i.e. send_rxmsg(string) ).  I also have a few
  155. Xroutines to work with ARP, and chances are they will be in the next
  156. Xrelease too.
  157. X
  158. X    I hope that this library will now make it easy for you to say - "Hey
  159. XI've got this neat idea, let me do it."  Instead of (what I used to do)
  160. X"Aww man, it's too much hassle to open a {window,screen,gadget}".
  161. X
  162. X    I would also like feedback on these routines and ways to improve them.
  163. XThey work fine for me, but maybe not for you.  If so, lemme know.
  164. X
  165. X
  166. X--dominic giampaolo
  167. X  Appt. # 8067 West
  168. X  4201 Mass. Ave.
  169. X  Washington, D.C. 20016
  170. X
  171. XE-Mail    :    nick@chopin.uunet.uu.net     >
  172. X             or          |
  173. X           uunet!chopin!nick     >---- preferred
  174. X             or          |
  175. X        chopin!nick@uunet.uu.net     >
  176. X             or
  177. X          giampal@auvm.bitnet
  178. X
  179. X
  180. END_OF_FILE
  181. if test 5223 -ne `wc -c <'README'`; then
  182.     echo shar: \"'README'\" unpacked with wrong size!
  183. fi
  184. # end of 'README'
  185. fi
  186. if test ! -d 'demo_src' ; then
  187.     echo shar: Creating directory \"'demo_src'\"
  188.     mkdir 'demo_src'
  189. fi
  190. if test ! -d 'demo_src/frac' ; then
  191.     echo shar: Creating directory \"'demo_src/frac'\"
  192.     mkdir 'demo_src/frac'
  193. fi
  194. if test -f 'demo_src/frac/frac.c' -a "${1}" != "-c" ; then 
  195.   echo shar: Will not clobber existing file \"'demo_src/frac/frac.c'\"
  196. else
  197. echo shar: Extracting \"'demo_src/frac/frac.c'\" \(1451 characters\)
  198. sed "s/^X//" >'demo_src/frac/frac.c' <<'END_OF_FILE'
  199. X/* this program generates psuedo-fractal mountains using a
  200. X * random midpoint displacement algorithim (sounds fancy eh :)
  201. X *
  202. X * It is taken from Pokorny & Gerald, _Computer Graphics_ (the chapter
  203. X * on fractals)
  204. X *
  205. X * D.B.G. August 90.
  206. X */
  207. X#include <ezlib.h>
  208. X#include <math.h>
  209. X
  210. X#define MAX 640
  211. X
  212. X/* NOTE:  It is **very** important to declare functions that return doubles
  213. X *      as double.  If not, Manx gleefully fucks up your code by converting
  214. X *      everything to int.
  215. X */
  216. Xdouble ran();
  217. X
  218. Xdouble line[MAX];
  219. Xdouble rug = 0.3;
  220. Xstruct Screen *screen = NULL;
  221. X
  222. Xmain()
  223. X{
  224. X struct RastPort *rp;
  225. X int i, j;
  226. X double temp1;
  227. X
  228. X srand(time(0L));    /* I think this may be wrong here.... */
  229. X
  230. X line[0] = line[MAX-1] = (double) ((rand() % 50)+100);  /* seed it */
  231. X
  232. X fracline(0, MAX-1);   /* generate the "mountain" */
  233. X
  234. X screen = makescreen(HIRES, 2);    /* get a custom screen */
  235. X if (screen == NULL)
  236. X   { closelibs(); MSG("Opening Screen failed.\n"); exit(10); }
  237. X
  238. X rp = &screen->RastPort;
  239. X
  240. X Move(rp, 0L, (int) line[0]);
  241. X for (i=1; i < MAX; i++)
  242. X   Draw(rp, i, (int) line[i]);
  243. X
  244. X Delay(100);
  245. X killscreen(screen);
  246. X closelibs();
  247. X
  248. X exit(0);
  249. X}
  250. X
  251. Xfracline(a, b)
  252. X  int a, b;
  253. X{
  254. X register int mid;
  255. X double temp1, temp2;
  256. X
  257. X if ( (b - a) > 1 ) {
  258. X   mid = (a + b) / 2;
  259. X
  260. X   temp1 = (double) ((line[a] + line[b]) / 2);
  261. X   temp2 = (ran() * 2.0) - 1.0;
  262. X   temp2 = temp2 * ((double)(b - a)) * rug;
  263. X   line[mid] = (double) (temp1 + temp2);
  264. X
  265. X   fracline(a, mid);
  266. X   fracline(mid, b);
  267. X }
  268. X}
  269. X
  270. X
  271. END_OF_FILE
  272. if test 1451 -ne `wc -c <'demo_src/frac/frac.c'`; then
  273.     echo shar: \"'demo_src/frac/frac.c'\" unpacked with wrong size!
  274. fi
  275. # end of 'demo_src/frac/frac.c'
  276. fi
  277. if test -f 'demo_src/frac/makefile' -a "${1}" != "-c" ; then 
  278.   echo shar: Will not clobber existing file \"'demo_src/frac/makefile'\"
  279. else
  280. echo shar: Extracting \"'demo_src/frac/makefile'\" \(87 characters\)
  281. sed "s/^X//" >'demo_src/frac/makefile' <<'END_OF_FILE'
  282. Xfrac : frac.c
  283. X    cc +L +Ivd0:include/header.h frac.c
  284. X    ln +Q -o frac frac.o -lez -lm -lc
  285. X
  286. END_OF_FILE
  287. if test 87 -ne `wc -c <'demo_src/frac/makefile'`; then
  288.     echo shar: \"'demo_src/frac/makefile'\" unpacked with wrong size!
  289. fi
  290. # end of 'demo_src/frac/makefile'
  291. fi
  292. if test ! -d 'demo_src/sin' ; then
  293.     echo shar: Creating directory \"'demo_src/sin'\"
  294.     mkdir 'demo_src/sin'
  295. fi
  296. if test -f 'demo_src/sin/makefile' -a "${1}" != "-c" ; then 
  297.   echo shar: Will not clobber existing file \"'demo_src/sin/makefile'\"
  298. else
  299. echo shar: Extracting \"'demo_src/sin/makefile'\" \(82 characters\)
  300. sed "s/^X//" >'demo_src/sin/makefile' <<'END_OF_FILE'
  301. Xsin : sin.c
  302. X    cc +ff +L +Ivd0:include/header.h sin.c
  303. X    ln -o sin sin.o -lez -lm -lc
  304. END_OF_FILE
  305. if test 82 -ne `wc -c <'demo_src/sin/makefile'`; then
  306.     echo shar: \"'demo_src/sin/makefile'\" unpacked with wrong size!
  307. fi
  308. # end of 'demo_src/sin/makefile'
  309. fi
  310. if test -f 'demo_src/sin/sin.c' -a "${1}" != "-c" ; then 
  311.   echo shar: Will not clobber existing file \"'demo_src/sin/sin.c'\"
  312. else
  313. echo shar: Extracting \"'demo_src/sin/sin.c'\" \(3150 characters\)
  314. sed "s/^X//" >'demo_src/sin/sin.c' <<'END_OF_FILE'
  315. X/* This program draws Lissajous curves.  It is taken directly from the
  316. X * chapter 3 exercises in a book called _Computer Graphics: The Principles
  317. X * Behind the Art and Science_.  That book is written by Pokorny &
  318. X * Gerald.
  319. X *
  320. X * Believe it or not the Amiga is actually mentioned in that book! ;^)
  321. X */
  322. X
  323. X#include <stdio.h>
  324. X#include <math.h>
  325. X#include <ezlib.h>
  326. X
  327. X#define MAX 320
  328. X
  329. Xdouble sin_tab[360], cos_tab[360];
  330. X
  331. X/* first we allocate two screens, set up some colors and make sure that
  332. X * all worked.
  333. X *
  334. X * Then we fill in a table so we don't have keep calling the sin() function
  335. X * when draw the actual curves.
  336. X *
  337. X * Finally we scroll the picture off the screen using a simple double
  338. X * buffering technique.
  339. X */
  340. X
  341. Xmain()
  342. X{
  343. X register int i;
  344. X int j, count = 0;
  345. X double ang, step, hold_x, hold_y;
  346. X struct Screen *screen1, *screen2;
  347. X struct BitMap *bm1, *bm2;
  348. X struct RastPort *rp, *rp2;
  349. X
  350. X screen2 = makescreen(HIRES, 3);
  351. X if (screen2 == NULL)
  352. X   exit(10L);
  353. X
  354. X setcolor(screen2, 0, BLACK); setcolor(screen2, 1, WHITE);
  355. X setcolor(screen2, 2, BLUE);  setcolor(screen2, 5, GREEN);
  356. X setcolor(screen2, 3, PINK);  setcolor(screen2, 4, ORANGE);
  357. X setcolor(screen2, 6, GREY);  setcolor(screen2, 7, RED);
  358. X
  359. X screen1 = makescreen(HIRES, 3);
  360. X if (screen1 == NULL)
  361. X   { killscreen(screen2); exit(10L); }
  362. X
  363. X setcolor(screen1, 0, BLACK); setcolor(screen1, 1, WHITE);
  364. X setcolor(screen1, 2, BLUE);  setcolor(screen1, 5, GREEN);
  365. X setcolor(screen1, 3, PINK);  setcolor(screen1, 4, ORANGE);
  366. X setcolor(screen1, 6, GREY);  setcolor(screen1, 7, RED);
  367. X
  368. X rp = &screen1->RastPort;  rp2 = &screen2->RastPort;
  369. X bm1 = &screen1->BitMap;   bm2 = &screen2->BitMap;
  370. X
  371. X /* this loop fills up a table with a sine curve     */
  372. X /* the magic number 0.01745 is radians per degree     */
  373. X for(i=0; i < 360; i++) {
  374. X   sin_tab[i] = sin(0.01745 * (double)i);
  375. X   cos_tab[i] = cos(0.01745 * (double)i);
  376. X }
  377. X
  378. X step = (double)360 /  (double)MAX;
  379. X Move(rp, 320, 100+90);
  380. X for(j=90; j > 30; j -= 2) {
  381. X   ang = 0.0;
  382. X   for(i=0; i < MAX; i++) {
  383. X     hold_x =  sin_tab[ (2 * (int)ang) % 360] * (double)j * 2.0;
  384. X     hold_y =  cos_tab[ (3 * (int)ang) % 360] * (double)j;
  385. X     Draw(rp, 320+ (int)hold_x, 100+(int)hold_y);
  386. X     ang = ang + step;
  387. X   }
  388. X   SetAPen(rp, (count++ % 8));
  389. X }
  390. X
  391. X Delay(125);
  392. X
  393. X /* now the curve has been fully drawn to the screen.
  394. X  * First we'll copy it to the second screen behind this one, then
  395. X  * we'll double buffer it off the screen
  396. X  */
  397. X
  398. X /* scroll curve smoothly off the screen using double buffering */
  399. X for(i=140; i > 4; i-=8) {
  400. X   WaitTOF();
  401. X   BltBitMap(bm1, i,0,  bm2, i-4,0,  380,200,  0x0c0,0xff);
  402. X   ScreenToFront(screen2);
  403. X   WaitTOF();
  404. X   BltBitMap(bm2, i-4,0,  bm1, i-8,0,  380,200,  0x0c0,0xff);
  405. X   ScreenToFront(screen1);
  406. X }
  407. X
  408. X /* reached left edge, so from here we do things slightly different
  409. X  * than above
  410. X  */
  411. X for(i=2; i < 70 ; i++) {
  412. X   WaitTOF();
  413. X   BltBitMap(bm1, i,0,  bm2, 0,0,  380-i,200,  0x0c0,0xff);
  414. X   ScreenToFront(screen2);
  415. X   WaitTOF();
  416. X   BltBitMap(bm2, i,0,  bm1, 0,0,  380-i,200,  0x0c0,0xff);
  417. X   ScreenToFront(screen1);
  418. X }
  419. X
  420. X /* de-allocate everything and exit.  Simple eh? ;^) */
  421. X killscreen(screen1);
  422. X killscreen(screen2);
  423. X
  424. X closelibs();
  425. X exit(0L);
  426. X}
  427. X
  428. END_OF_FILE
  429. if test 3150 -ne `wc -c <'demo_src/sin/sin.c'`; then
  430.     echo shar: \"'demo_src/sin/sin.c'\" unpacked with wrong size!
  431. fi
  432. # end of 'demo_src/sin/sin.c'
  433. fi
  434. if test ! -d 'doc' ; then
  435.     echo shar: Creating directory \"'doc'\"
  436.     mkdir 'doc'
  437. fi
  438. if test -f 'doc/closelibs.doc' -a "${1}" != "-c" ; then 
  439.   echo shar: Will not clobber existing file \"'doc/closelibs.doc'\"
  440. else
  441. echo shar: Extracting \"'doc/closelibs.doc'\" \(419 characters\)
  442. sed "s/^X//" >'doc/closelibs.doc' <<'END_OF_FILE'
  443. XFUNCTION  closelibs()  -  close any previously opened libraries
  444. X
  445. X   closelibs()
  446. X
  447. XThis function will close any previously opened libraries.  If you can
  448. Xopen it with openlibs() - this function will close it.  Doesn't take
  449. Xany parameters and all it does is call CloseLibrary() for each currently
  450. Xopened library.
  451. X
  452. X
  453. XTODO : Need to support the other libraries that I eventually support in
  454. X       openlibs().
  455. X
  456. X
  457. XBUGS : None.
  458. X
  459. X
  460. END_OF_FILE
  461. if test 419 -ne `wc -c <'doc/closelibs.doc'`; then
  462.     echo shar: \"'doc/closelibs.doc'\" unpacked with wrong size!
  463. fi
  464. # end of 'doc/closelibs.doc'
  465. fi
  466. if test -f 'doc/create_boolgadget.doc' -a "${1}" != "-c" ; then 
  467.   echo shar: Will not clobber existing file \"'doc/create_boolgadget.doc'\"
  468. else
  469. echo shar: Extracting \"'doc/create_boolgadget.doc'\" \(2082 characters\)
  470. sed "s/^X//" >'doc/create_boolgadget.doc' <<'END_OF_FILE'
  471. XFUNCTION   create_boolgadget()  -  create a fully spec'ed Boolean gadget
  472. X
  473. Xstruct Gadget *create_boolgadget(l_edge, t_edge, flags, activation, text, id)
  474. X         SHORT l_edge, t_edge;
  475. X         USHORT flags, activation;
  476. X         UBYTE *text;
  477. X         USHORT id;
  478. X
  479. X    This function gives you total control for easily creating boxed boolean
  480. Xgadgets of all types.  You specify exactly the flags and activation types
  481. Xof the gadget and where the top corner should be, and the rest is taken
  482. Xcare of.  The text you specify is centered in the gadget and the gadget has
  483. Xthe ID you give.
  484. X
  485. X    You can specify any types of flags you would like, however not much
  486. Xerror checking is done on these values.  Be careful for silly combinations.
  487. XYou should also remember that you MUST specify either GADGHBOX or GADGHCOMP
  488. Xfor the flags argument.  It is also useful to at minimum specify RELVERIFY
  489. Xfor the Activation argument.  Finally, you should make sure that your
  490. Xwindow is listening for Gadget messages (either gadget UP or gadget DOWN).
  491. X
  492. X    This function will NOT add the gadget to your window.  This is
  493. Xsomething you must do afterwards else you will never see your gadget.  The
  494. Xonly thing this function does is to allocate space and return a pointer to
  495. Xthe properly filled out structure.
  496. X
  497. X    The following example will create a boolean gadget at 100,25
  498. Xwhich is highlighted by a box.    The text inside the gadget will be
  499. X"Don't have a cow dude" and the gadget will have an id of 42.
  500. X
  501. X       struct Window *win;        /* assume opened earlier */
  502. X       struct Gadget *gadg;
  503. X       char *string = "Don't have a cow dude";
  504. X
  505. X       gadg = create_boolgadget(100,25, GADGHBOX, RELVERIFY, string, 42);
  506. X       if (gadg == NULL)
  507. X     error_no_gadg();
  508. X
  509. X       /* add it to the window and make it appear */
  510. X       AddGadget(gadg, win, NULL);
  511. X       RefreshGList(gadg, win, NULL, 1);
  512. X
  513. X
  514. XTODO : should provide a way for specifying custom imagery.  Most likely
  515. X       that will have to be a seperate call.
  516. X
  517. XBUGS : maybe, maybe not (preferably the latter).
  518. X
  519. XSEE ALSO : makeboolgadget(), killgadget(), getyn(), getstring(),
  520. X       makewindow()
  521. X
  522. X
  523. END_OF_FILE
  524. if test 2082 -ne `wc -c <'doc/create_boolgadget.doc'`; then
  525.     echo shar: \"'doc/create_boolgadget.doc'\" unpacked with wrong size!
  526. fi
  527. # end of 'doc/create_boolgadget.doc'
  528. fi
  529. if test -f 'doc/createwindow.doc' -a "${1}" != "-c" ; then 
  530.   echo shar: Will not clobber existing file \"'doc/createwindow.doc'\"
  531. else
  532. echo shar: Extracting \"'doc/createwindow.doc'\" \(2118 characters\)
  533. sed "s/^X//" >'doc/createwindow.doc' <<'END_OF_FILE'
  534. XFUNCTION  createwindow()  -  create a fully spec'ed Intuition window
  535. X
  536. X       struct Window *createwindow(screen, flags, idcmp,
  537. X                       leftedge, topedge,
  538. X                       width, height)
  539. X               struct Screen *screen;
  540. X               ULONG flags, idcmp;
  541. X               int leftedge, topedge, width, height;
  542. X
  543. X    This function allows you the most flexibility over specifying a window.
  544. XEssentially, you can create any type of window you would like with this
  545. Xcall.  Flags and idcmp are exactly as you would specify in a NewWindow
  546. Xstructure, and are passed directly through.  If you specify screen as
  547. Xnon-NULL, the window will be opened on that screen.
  548. X
  549. X    Some error checking of your position variables is done, however it is
  550. Xstill possible to screw yourself if you get too outlandish (like negative
  551. Xleftedge, etc).  Keep this in mind if passing negative numbers could be a
  552. Xproblem.
  553. X
  554. X    A pointer to the freshly created window will be returned, or NULL if
  555. Xthe window could not be opened.  You should definitely error check the
  556. Xreturn from this function.
  557. X
  558. X    To open a simple window with only a title bar, disk inserted messages
  559. Xfrom Intuition, at 100,50 and 200 pixels wide by 75 pixels high, you would
  560. Xdo the following :
  561. X
  562. X      struct Window *win;
  563. X
  564. X      win = createwindow(NULL, WINDOWDRAG, DISKINSERTED, 100,50, 200, 75)
  565. X      if (win == NULL)
  566. X    no_window();
  567. X
  568. X   The function call above simply asks for a window with a title bar, and
  569. Xan Intuition port to which DISKINSERTED messages will arrive.  The window
  570. Xwould have a top corner at 100,50, and would be 200 pixels wide and 75
  571. Xpixels high.
  572. X
  573. X   Of course you can specify any combination of flags and idcmp messages.
  574. XYou must make sure they make sense to your application however.  For
  575. Xexample it would not make much sense to ask for CLOSEWINDOW Intuition
  576. Xmessages if you have not asked for a Close Gadget in the flags variable.
  577. X
  578. X
  579. XTODO : probably should error check the flags/idcmp arguments and modify the
  580. X       flags argument to agree with the idcmp arg.  This would be to take
  581. X       care of problems such as in the last paragraph.
  582. X
  583. XBUGS : bunny?
  584. X
  585. XSEE ALSO : makewindow(), makescreen()
  586. X
  587. X
  588. X
  589. X
  590. END_OF_FILE
  591. if test 2118 -ne `wc -c <'doc/createwindow.doc'`; then
  592.     echo shar: \"'doc/createwindow.doc'\" unpacked with wrong size!
  593. fi
  594. # end of 'doc/createwindow.doc'
  595. fi
  596. if test -f 'doc/defines.doc' -a "${1}" != "-c" ; then 
  597.   echo shar: Will not clobber existing file \"'doc/defines.doc'\"
  598. else
  599. echo shar: Extracting \"'doc/defines.doc'\" \(3968 characters\)
  600. sed "s/^X//" >'doc/defines.doc' <<'END_OF_FILE'
  601. XMACROS         this file describes several macros that have been defined
  602. X         in ezlib.h
  603. X
  604. X    The file ezlib.h contains a few macros to 1) in general make life a
  605. Xlittle easier, and 2) to facilitate working with ez.lib.
  606. X
  607. X    As mentioned in openlibs.doc, there are several numbers defined to
  608. Xspecify which libraries to open in a call to openlibs().  They are:
  609. X
  610. X            #define GFX     0x001
  611. X            #define INTUI    0x002
  612. X            #define INTUITION    0x002
  613. X            #define ARP     0x004
  614. X            #define DFONT    0x008
  615. X            #define DISKFONT    0x008
  616. X            #define TRANSLATOR    0x010
  617. X            #define REXX    0x100
  618. X
  619. X    As you can see, they are readily or'ed together to open several
  620. X    libraries at once.     Not much else to say here.
  621. X
  622. X----------------------------------------------------------------------
  623. X
  624. X    Next there is the MSG() macro taken from an old Transactor.  This is a
  625. Xsimple macro to put out a string onto whatever output stream may be
  626. Xattatched to your program (i.e. whether from WorkBench or the CLI).  It is
  627. Xdefined as follows :
  628. X
  629. X       #define MSG(a) (Write(Output(), a, strlen(a)))
  630. X
  631. X    Again, it will simply dump out a string onto your output stream.  Note
  632. Xthat it is NOT the same as a printf() call and does NOT take formatting
  633. Xarguments as does printf().
  634. X
  635. X----------------------------------------------------------------------
  636. X
  637. X
  638. X    Following are macros to set the colors on a custom screen.    Several
  639. X"colors" have also been defined.  The macro is setcolor() and is called
  640. Xlike this :
  641. X
  642. X      setcolor(screen, num, color)
  643. X
  644. XScreen is the pointer to your custom screen which you opened earlier with
  645. Xmakescreen() or similar.
  646. X
  647. XNum is the number of the color register you wish to set.  The highest color
  648. Xregister which you can set is dependent on the depth of the depth (in
  649. Xbitplanes) of your screen.  In any case, it will never be more than 32.
  650. X
  651. XColor is the actual color you wish to set.  It is a number between 0 and
  652. X4,095.    Essentially, only the first twelve (12) bits matter.  The color
  653. Xdefined by your number is as follows:  The first 4 bits (0-3) are BLUE.
  654. XThe next 4 bits (4-7) are GREEN, and the next 4 bits (8-11) are RED.  To
  655. Xdefine a pure blue color, you would specify (in hex) 0x00f.  A nice purple
  656. Xwould be (again in hex) 0xf0f.  To save you the hassle of figuring out what
  657. Xcolor is what, I have defined the following colors in ezlib.h :
  658. X
  659. X    BLACK    WHITE    RED    GREEN    BLUE    YELLOW
  660. X    PINK     PURPLE   GREY0  GREY1    GREY2   GREY3
  661. X    ORANGE   INDIGO   CYAN   GOLD
  662. X
  663. X    For example to set the background color of your screen to GREEN, all
  664. Xyou need do (after having opened a screen) is the following:
  665. X
  666. X            setcolor(screen, 0, GREEN);
  667. X
  668. X For the curious, setcolor() calls SetRGB4().
  669. X
  670. X----------------------------------------------------------------------
  671. X
  672. X
  673. X    The are 5 more #defines.  They are :
  674. X
  675. X          initgfx()    -  simply a call to openlibs(GFX)
  676. X         closegfx()    -  simply a call to closelibs (be careful as
  677. X                  this will also close everything else)
  678. X
  679. X    Print(rp, string)  -  Call this with a RastPort pointer and a
  680. X                  a string.  That string will be printed
  681. X                  starting at the current pen location in
  682. X                  that RastPort.
  683. X
  684. X     Circle(rp, x, y, rad) -  Draw a circle at x,y with radius rad in the
  685. X                  rastport pointed to by rp.
  686. X
  687. X  Line(rp, x1, y1, x2, y2) -  Draw a line from x1,y1 to x2,y2.  Believe it or
  688. X                  not, there is no function like this in Gfxlib.
  689. X                  You are supposed to Move() then Draw().  This
  690. X                  macro takes care of that for you.
  691. X
  692. X    Remember, the last 3 "functions" are really just #defines, so there is
  693. Xno overhead in calling them.
  694. X
  695. X----------------------------------------------------------------------
  696. X
  697. X
  698. X    That about covers the ezlib.h file.  I have also defined some
  699. Xfunctions and their return values, but not having an ANSI compiler I
  700. Xhaven't prototyped them.  This would be a *very* good idea to do (so would
  701. Xgetting an ANSI compiler ;-).
  702. X
  703. X
  704. XTODO - can't think of anything
  705. X
  706. XBUGS - in a #define ?  ;-)
  707. X
  708. X
  709. END_OF_FILE
  710. if test 3968 -ne `wc -c <'doc/defines.doc'`; then
  711.     echo shar: \"'doc/defines.doc'\" unpacked with wrong size!
  712. fi
  713. # end of 'doc/defines.doc'
  714. fi
  715. if test -f 'doc/free_bitmap.doc' -a "${1}" != "-c" ; then 
  716.   echo shar: Will not clobber existing file \"'doc/free_bitmap.doc'\"
  717. else
  718. echo shar: Extracting \"'doc/free_bitmap.doc'\" \(741 characters\)
  719. sed "s/^X//" >'doc/free_bitmap.doc' <<'END_OF_FILE'
  720. XFUNCTION  free_bitmap()  -  Free up a previously allocated bitmap struct
  721. X
  722. X       free_bitmap(bm, width, height)
  723. X      struct BitMap *bm;
  724. X      int width, height;
  725. X
  726. X    This function will simply free up all the resources taken by the given
  727. Xbitmap.  The BitMap structure itself is freed, and should no longer be used
  728. Xafter this function.
  729. X
  730. X   Just make sure to call this function on a previously allocated bitmap,
  731. Xand not something like your custom screen bitmap.  Preferably you would
  732. Xhave used something like getbitmap() to allocate the bitmap you wish to
  733. Xfree.
  734. X
  735. XTODO : maybe get rid of the width,height arguments?  could calculate it
  736. X       internally, but I might be off
  737. X
  738. XBUGS : roaches, ants, gnats, etc...
  739. X
  740. XSEE ALSO : getbitmap(), makescreen()
  741. X
  742. END_OF_FILE
  743. if test 741 -ne `wc -c <'doc/free_bitmap.doc'`; then
  744.     echo shar: \"'doc/free_bitmap.doc'\" unpacked with wrong size!
  745. fi
  746. # end of 'doc/free_bitmap.doc'
  747. fi
  748. if test -f 'doc/getbitmap.doc' -a "${1}" != "-c" ; then 
  749.   echo shar: Will not clobber existing file \"'doc/getbitmap.doc'\"
  750. else
  751. echo shar: Extracting \"'doc/getbitmap.doc'\" \(1244 characters\)
  752. sed "s/^X//" >'doc/getbitmap.doc' <<'END_OF_FILE'
  753. XFUNCTION   getbitmap()  -  allocate and initialize an arbitrary bitmap
  754. X
  755. X     struct BitMap *getbitmap(depth, width, height)
  756. X        int depth, width, height;
  757. X
  758. X    This function will return a pointer to a bitmap of your specified
  759. Xdepth, width, and height.   It will return NULL if any of the memory
  760. Xallocations fail (of course taking care to free any memory it has already
  761. Xallocated).
  762. X
  763. X    Note that the depth variable has a maximum value of 8.  If you ask for
  764. Xmore, the call will fail immediately.
  765. X
  766. X    In this example, we will allocate a secondary 3 bitplane bitmap of
  767. X100x75 pixels.    This could be very useful for calls to BltBitMap() :
  768. X
  769. X      struct BitMap *bm;
  770. X
  771. X      bm = getbitmap(3, 100, 75);
  772. X      if (bm == NULL)
  773. X    no_bitmap();
  774. X
  775. X      /* continue doing stuff ... */
  776. X
  777. X      /* free up all that allocated memory */
  778. X      free_bitmap(bm, 100, 75);
  779. X
  780. X    This call is basically useful for allocating backup storage for making
  781. Xcalls to BltBitMap() (or its cousins).  Just remember to check the error
  782. Xreturn, and other than that you get a fully initialized and allocated
  783. Xbitmap structure to your specs! ;^)
  784. X
  785. XTODO : can't think of much else....
  786. X
  787. XBUGS : what's up doc?
  788. X
  789. XELMER FUDD : come here you silly wabbit!
  790. X
  791. XSEE ALSO : free_bitmap(), makescreen()
  792. X
  793. END_OF_FILE
  794. if test 1244 -ne `wc -c <'doc/getbitmap.doc'`; then
  795.     echo shar: \"'doc/getbitmap.doc'\" unpacked with wrong size!
  796. fi
  797. # end of 'doc/getbitmap.doc'
  798. fi
  799. if test -f 'doc/getfont.doc' -a "${1}" != "-c" ; then 
  800.   echo shar: Will not clobber existing file \"'doc/getfont.doc'\"
  801. else
  802. echo shar: Extracting \"'doc/getfont.doc'\" \(2293 characters\)
  803. sed "s/^X//" >'doc/getfont.doc' <<'END_OF_FILE'
  804. XFUNCTION   getfont()   - open a disk font for use.
  805. X
  806. X   struct TextFont *getfont(name size)
  807. X              char *name;
  808. X              int size;
  809. X
  810. X    Getfont() gives you easy access to the disk based fonts of the Amiga.
  811. XAll you have to do is pass the name (a character string) of the font and
  812. Xthe size you would like.  If opening the font succeeds, you will be able to
  813. Ximmediately SetFont(rp, text_font) in your current window and use it from
  814. Xthen on (with the Text() function).  This function returns NULL if anything
  815. Xfails.
  816. X
  817. X    The name you pass to getfont() can have a ".font" extension or not.  If
  818. Xit doesn't, then it will be appended.  Also be aware that if you specify a
  819. Xfull pathname for name, that font need NOT be in the current FONTS:
  820. Xdirectory.  This is a little known but true fact.
  821. X
  822. X    Size should simply be the point size of the font you want.    For example
  823. Xif you want Times 17, you would use size == 17.
  824. X
  825. X    To open a font called "helvetica" in a 23 point size you would do this:
  826. X
  827. X    struct Window *wind;    /* assume we opened it earlier */
  828. X    struct TextFont *tf;
  829. X
  830. X    /* open the font and error check the result */
  831. X    tf = getfont("helvetica", 23);
  832. X    if (tf == NULL)
  833. X      no_font();
  834. X
  835. X    SetFont(wind->RPort, tf);    /* from now on we can use the font */
  836. X
  837. X      .....      /* do other stuff */
  838. X
  839. X    CloseFont(tf);           /* do this BEFORE calling killwindow() */
  840. X
  841. X
  842. XNOTE : You should call CloseFont() before calling killwindow().  This will
  843. X       prevent fonts from being kept in memory unnecessarily.  It is best
  844. X       if you can call CloseFont() as soon as you are done with the font.
  845. X       This prevents wasting memory.
  846. X
  847. X
  848. X    Essentially, there are 3 steps to using a disk font.  Open the font
  849. Xwith getfont().  Then call SetFont() for the window/screen you wish to use
  850. Xthe font on.  Then use the graphics library text routines for whatever you
  851. Xwant.  Finally call CloseFont() when you are done.  Nice and easy.
  852. X
  853. X
  854. X
  855. XTODO : should probably be some sort of resource tracking so that you don't
  856. X       have to call CloseFont().
  857. X
  858. X       would be nice if there was a single call you could make to open and
  859. X       set the font for a window (and then not have to worry about after
  860. X       that because of the item above).
  861. X
  862. X
  863. XBUGS : ha! c'mon -(;-)    (smiley with a mohawk!)
  864. X
  865. XSEE ALSO : makewindow(); makescreen();
  866. X
  867. X
  868. END_OF_FILE
  869. if test 2293 -ne `wc -c <'doc/getfont.doc'`; then
  870.     echo shar: \"'doc/getfont.doc'\" unpacked with wrong size!
  871. fi
  872. # end of 'doc/getfont.doc'
  873. fi
  874. if test -f 'doc/getstring.doc' -a "${1}" != "-c" ; then 
  875.   echo shar: Will not clobber existing file \"'doc/getstring.doc'\"
  876. else
  877. echo shar: Extracting \"'doc/getstring.doc'\" \(2475 characters\)
  878. sed "s/^X//" >'doc/getstring.doc' <<'END_OF_FILE'
  879. XFUNCTION  getstring()  -  Get a string from the user, using a window
  880. X
  881. X  char *getstring(screen, title, def_string)
  882. X      struct Screen *screen;
  883. X      char *title;
  884. X      char *def_string;
  885. X
  886. X    This function will pop open a window to prompt the user for a string.
  887. XThe window has o.k. and cancel gadgets, and in addition, a Close gadget.
  888. XThe string you wish to get should be less than 256 characters (the default
  889. Xbuffer size).
  890. X
  891. X    The screen argument is a pointer to a screen on which to open the
  892. Xnew window.  The screen argument can be NULL in which case the window will
  893. Xsimply appear on the Workbench screen.    The title argument will be the
  894. Xtitle of the new window.   The def_string argument is a pointer to the
  895. Xdefault string that will appear in the string gadget.
  896. X
  897. X    This function will return NULL if the user clicks the Close Gadget or
  898. Xclicks the cancel gadget.  If they click the "OK" gadget or press return in
  899. Xthe string gadget, you will get a pointer to a string back.  The string is
  900. Xdynamically allocated and you must free it when you are done with a call to
  901. XFreeMem() (see below).
  902. X
  903. X     Here is an example that gets back the users name and prints it in the
  904. X     CLI window.  In this example, the window will appear on workbench,
  905. X     have a window title "Please enter your name", and there will be no
  906. X     default string.
  907. X
  908. X     char *string;
  909. X
  910. X     string = getstring(NULL, "Please enter your name", NULL);
  911. X
  912. X     if (string == NULL)
  913. X       printf("User does not have a name.\n");
  914. X     else {
  915. X       printf("Your name is %s.\n", string);
  916. X
  917. X       /* for this example we are done with the string, so we will free
  918. X    * it now.
  919. X    *        !!!!!! **  NOTICE  ** !!!!!!
  920. X    *   You should be very careful to make sure that you free the
  921. X    * proper amount of memory using the following style call.
  922. X    * The size you MUST free is the length of the string + 1.
  923. X    * This is VERY IMPORTANT as otherwise you mess up memory.
  924. X    */
  925. X       FreeMem(string, strlen(string)+1);
  926. X     }                /*  ^^^^ The +1 is _very_ important! */
  927. X
  928. X
  929. X    Again, if you want this window to appear on a custom screen (opened by
  930. Xa call to makescreen() or similar) you should pass it the screen pointer
  931. Xinstead of NULL as the first argument.
  932. X
  933. X    You should also check to make sure you didn't get back an empty string.
  934. X
  935. X
  936. X
  937. XTODO : Probably should (again) make this into a higher level routine with
  938. X       lower level support routines.  For now this works however.
  939. X
  940. XBUGS : None to the best of my knowledge.
  941. X
  942. XSEE ALSO : getyn(); makewindow()
  943. X
  944. END_OF_FILE
  945. if test 2475 -ne `wc -c <'doc/getstring.doc'`; then
  946.     echo shar: \"'doc/getstring.doc'\" unpacked with wrong size!
  947. fi
  948. # end of 'doc/getstring.doc'
  949. fi
  950. if test -f 'doc/getyn.doc' -a "${1}" != "-c" ; then 
  951.   echo shar: Will not clobber existing file \"'doc/getyn.doc'\"
  952. else
  953. echo shar: Extracting \"'doc/getyn.doc'\" \(1990 characters\)
  954. sed "s/^X//" >'doc/getyn.doc' <<'END_OF_FILE'
  955. XFUNCTION   getyn()  -  get a yes or no answer using a requestor
  956. X
  957. X      getyn(window, string)
  958. X    struct Window *window;
  959. X    char *string;
  960. X
  961. X    This function will get a simple yes or no answer from a user.  You pass
  962. Xgetyn() a string which is put into an AutoRequest().  If the user clicks
  963. Xo.k., TRUE is returned, otherwise FALSE.  This function is useful in many
  964. Xsituations to just let the user know what is going on, and of course for
  965. Xyes/no questions.
  966. X
  967. X    If you pass getyn() a NULL window pointer, it will return NULL to you.
  968. XIf for any reason the AutoRequest() can not be made, this function will
  969. Xalso return NULL.  Therefore you should keep this in mind when you use
  970. Xgetyn().  Also note that if there isn't enough memory for a full
  971. XAutoRequest() (similar to the Insert Volume xxx requestors), the getyn()
  972. Xfunction will degenerate into a display alert (a recoverable guru box!).
  973. XThis can be scary for novice users, but only happens in *very* low memory
  974. Xconditions.
  975. X
  976. X    The string you pass getyn() should fit horizontally on one line across
  977. Xthe display.  If not, the AutoRequest() will not open and you will get
  978. XNULL back.
  979. X
  980. X    Here is an example of using getyn() to find out if the user is really a
  981. Xweenie:
  982. X
  983. X       struct Window *wind;    /* assume it was opened earlier */
  984. X       int value;
  985. X
  986. X       value = getyn(wind, " Are you a weenie? ");
  987. X       if (value == TRUE)
  988. X     user_is_a_weenie();
  989. X       else
  990. X     user_is_cool();
  991. X
  992. X
  993. X    Likewise, if you would just like to inform the user that something has
  994. Xhappened or is about to happen, you can do the following:
  995. X
  996. X    struct Window *wind;     /* again, assume it was opened earlier */
  997. X
  998. X    /* doing some processing and something occurs */
  999. X
  1000. X    getyn(wind, " Did you know that XXX just happened? ");
  1001. X
  1002. X    /* keep going .... */
  1003. X
  1004. X
  1005. X
  1006. XTODO : would be nice if you could do multi-line requestors using some
  1007. X       sort of embedded character to signify a line break.
  1008. X
  1009. XBUGS : None at time of publication.
  1010. X
  1011. XSEE ALSO : getstring(); makewin(); makescreen();
  1012. X
  1013. X
  1014. END_OF_FILE
  1015. if test 1990 -ne `wc -c <'doc/getyn.doc'`; then
  1016.     echo shar: \"'doc/getyn.doc'\" unpacked with wrong size!
  1017. fi
  1018. # end of 'doc/getyn.doc'
  1019. fi
  1020. if test -f 'doc/killgadget.doc' -a "${1}" != "-c" ; then 
  1021.   echo shar: Will not clobber existing file \"'doc/killgadget.doc'\"
  1022. else
  1023. echo shar: Extracting \"'doc/killgadget.doc'\" \(1305 characters\)
  1024. sed "s/^X//" >'doc/killgadget.doc' <<'END_OF_FILE'
  1025. XFUNCTION  killgadget()  -  Remove and de-allocate a gadget
  1026. X
  1027. X       killgadget(win, gadg)
  1028. X     struct Window    *win;
  1029. X     struct Gadget    *gadg;
  1030. X
  1031. X    This function will remove a gadget from your window and de-allocate all
  1032. Xof its resources.  After this call, gadg will be invalid and will no
  1033. Xlonger appear in your window.
  1034. X
  1035. X    Unfortunately this call is not orthogonal to the rest of the kill()
  1036. Xfunctions, as it needs to know the window from whence it came (to be able
  1037. Xto make the gadget go away).
  1038. X
  1039. X    In case you would want to do this on your own, the memory that is freed
  1040. Xis as follows (in reverse order from how it was allocated) :
  1041. X
  1042. X       gadg->GadgetRender->XY   :  10 * sizeof(SHORT)
  1043. X       gadg->GadgetRender        :  sizeof(struct Border)
  1044. X       gadg->IText            :  sizeof(struct IntuiText)
  1045. X       gadg             :  sizeof(struct Gadget)
  1046. X
  1047. X
  1048. X    You should make sure that any dynamically allocated text that may be in
  1049. Xyour gadget is managed properly (by having a backup pointer or freeing it
  1050. Xbefore this call).
  1051. X
  1052. X    After this call, the specified gadget should no longer appear in your
  1053. Xwindow.
  1054. X
  1055. XTODO : maybe not require the window pointer.  could stuff the value in the
  1056. X       user data field, but then the user can't use that field.
  1057. X
  1058. XBUGS : shouldn't be
  1059. X
  1060. XSEE ALSO : makeboolgadet(), create_boolgadget(), getyn(), getstring()
  1061. X
  1062. X
  1063. END_OF_FILE
  1064. if test 1305 -ne `wc -c <'doc/killgadget.doc'`; then
  1065.     echo shar: \"'doc/killgadget.doc'\" unpacked with wrong size!
  1066. fi
  1067. # end of 'doc/killgadget.doc'
  1068. fi
  1069. if test -f 'doc/killscreen.doc' -a "${1}" != "-c" ; then 
  1070.   echo shar: Will not clobber existing file \"'doc/killscreen.doc'\"
  1071. else
  1072. echo shar: Extracting \"'doc/killscreen.doc'\" \(1213 characters\)
  1073. sed "s/^X//" >'doc/killscreen.doc' <<'END_OF_FILE'
  1074. XFUNCTION  killscreen()  -  (safely) Close a previously opened screen
  1075. X
  1076. X   killscreen(screen)
  1077. X     struct Screen *screen;
  1078. X
  1079. X    This function will close the screen you pass it.  If the screen has a
  1080. Xdepth of greater than 2 (depth > 2) the bitmap data will be freed also.  If
  1081. Xyou have changed the screen->ExtData field from what it originally was
  1082. Xjust after you called makescreen(), you should put it back to the
  1083. Xoriginal value BEFORE you make this call.  (The ExtData field points to
  1084. Xthe BitMap structure that was allocated when creating the screen - and
  1085. Xnote: this is not the same BitMap structure that is in your Screen struct).
  1086. X
  1087. X    If there are any windows left on the screen, this function will
  1088. Xwait for them to go away before closing.  Note that killscreen() will
  1089. Xkeep waiting forever until the windows are gone, so make sure that any
  1090. Xwindows without close gadgets/menus on them are closed before you call
  1091. Xthis.  Else you will be in an infinite (but slow) loop.  The point
  1092. Xhere is that if you have a borderless backdrop window on a screen, and
  1093. Xyou call killscreen() - you are screwed, glued, and tatooed unless
  1094. Xsomeone else closes that window for you.
  1095. X
  1096. X
  1097. XTODO : nothing
  1098. X
  1099. XBUGS : nope.
  1100. X
  1101. XSEE ALSO : killwindow()
  1102. X
  1103. X
  1104. X
  1105. END_OF_FILE
  1106. if test 1213 -ne `wc -c <'doc/killscreen.doc'`; then
  1107.     echo shar: \"'doc/killscreen.doc'\" unpacked with wrong size!
  1108. fi
  1109. # end of 'doc/killscreen.doc'
  1110. fi
  1111. if test -f 'doc/killwindow.doc' -a "${1}" != "-c" ; then 
  1112.   echo shar: Will not clobber existing file \"'doc/killwindow.doc'\"
  1113. else
  1114. echo shar: Extracting \"'doc/killwindow.doc'\" \(912 characters\)
  1115. sed "s/^X//" >'doc/killwindow.doc' <<'END_OF_FILE'
  1116. XFUNCTION  killwindow()  -  (safely) Close a previoulsy opened window
  1117. X
  1118. X    killwindow(window)
  1119. X      struct Window *window;
  1120. X
  1121. X    This function will close the window you pass it.  If you have menus
  1122. Xattatched to the window, they will be cleared before the window closes.
  1123. XHowever if you have already cleared the menus yourself (with
  1124. XClearMenuStrip() ), then you must NULL out the window->MenuStrip field
  1125. Xbefore you call killwindow().
  1126. X
  1127. X    There are no return values from this function.
  1128. X
  1129. X    It is safe to pass a NULL pointer to this function (it checks for
  1130. Xthat).    This function will also reply to any existing messages that are at
  1131. Xyour window->UserPort (making it safe to call anytime).
  1132. X
  1133. XTODO : Not really much else I can do.  Might possibly want to do some sort
  1134. X       of resource tracking using the UserData field (for gadgets etc).
  1135. X
  1136. XBUGS : you kidding? ;-)
  1137. X
  1138. XSEE ALSO : makewindow(); killscreen(); makescreen();
  1139. X
  1140. X
  1141. X
  1142. END_OF_FILE
  1143. if test 912 -ne `wc -c <'doc/killwindow.doc'`; then
  1144.     echo shar: \"'doc/killwindow.doc'\" unpacked with wrong size!
  1145. fi
  1146. # end of 'doc/killwindow.doc'
  1147. fi
  1148. if test -f 'doc/laced_wb.doc' -a "${1}" != "-c" ; then 
  1149.   echo shar: Will not clobber existing file \"'doc/laced_wb.doc'\"
  1150. else
  1151. echo shar: Extracting \"'doc/laced_wb.doc'\" \(335 characters\)
  1152. sed "s/^X//" >'doc/laced_wb.doc' <<'END_OF_FILE'
  1153. XFUNCTION   laced_wb()  -  Return true/false if WB is interlaced or not
  1154. X
  1155. X         int laced_wb()
  1156. X
  1157. X    This function will return TRUE if the current Workbench screen is
  1158. Xinterlaced, or FALSE if the current Workbench screen is non-interlaced.
  1159. X
  1160. XTODO : what else could there be for this one?
  1161. X
  1162. XBUGS : ha!
  1163. X
  1164. XSEE ALSO : makewindow(), makescreen()
  1165. X
  1166. END_OF_FILE
  1167. if test 335 -ne `wc -c <'doc/laced_wb.doc'`; then
  1168.     echo shar: \"'doc/laced_wb.doc'\" unpacked with wrong size!
  1169. fi
  1170. # end of 'doc/laced_wb.doc'
  1171. fi
  1172. if test -f 'doc/makeboolgadget.doc' -a "${1}" != "-c" ; then 
  1173.   echo shar: Will not clobber existing file \"'doc/makeboolgadget.doc'\"
  1174. else
  1175. echo shar: Extracting \"'doc/makeboolgadget.doc'\" \(2662 characters\)
  1176. sed "s/^X//" >'doc/makeboolgadget.doc' <<'END_OF_FILE'
  1177. XFUNCTION    makeboolgadget()   -  create an autosizing boolean gadget
  1178. X
  1179. X     struct Gadget *makeboolgadget(win, l_edge, t_edge, text, id)
  1180. X              struct Window *win;
  1181. X              SHORT l_edge, t_edge;
  1182. X              UBYTE *text;
  1183. X              USHORT id;
  1184. X
  1185. X    This function will create a boolean gadget in your window.    The gadget
  1186. Xwill have your specified text, and id.    The size is calculated
  1187. Xautomatically to nicely fit the given text (although there is a minimum
  1188. Xsize of 30 pixels).  The return value is a pointer to the created gadget.
  1189. XYou should keep this pointer so that you can later remove the gadget with a
  1190. Xcall to killgadget().
  1191. X
  1192. X    The gadget returned is dynamically allocated, so take care to call
  1193. Xkillgadget() when you are done with the gadget.  Note that you should call
  1194. Xkillgadget() before you call killwindow().
  1195. X
  1196. X    The created gadget will have the id you specify so that you will be
  1197. Xable to determine from your Intuition messages which gadget was pressed.
  1198. XYou should take care to make sure that you will receive the GADGETUP
  1199. Xmessages in your window.  Windows created with makewindow() do not receive
  1200. Xthese types of messages, however, you can use the Intuition function
  1201. XModifyIDCMP() to change this behavior.
  1202. X
  1203. X    The gadgets created by this call are simple box affairs with the
  1204. Xhighlight mode set to COMPLEMENT.  The text is centered and should be
  1205. Xoffset nicely.    The gadgets are not crowded or otherwise unsightly, except
  1206. Xfor being rather plain.
  1207. X
  1208. X    To create a boolean gadget with the text "Click Me", you would do the
  1209. Xfollowing (assuming an already opened window) :
  1210. X
  1211. X    struct Window *win;        /* opened beforehand */
  1212. X    struct Gadget *click_me;
  1213. X
  1214. X    click_me = makeboolgadget(win, 100, 25, "Click Me", 43);
  1215. X
  1216. X    /* do whatever we want (i.e. main loop, etc...)  */
  1217. X
  1218. X    /* free up gadget resources (i.e. memory) */
  1219. X    killgadget(win, click_me);
  1220. X
  1221. X    The previous code will create and cause to be displayed an autosized
  1222. Xboolean gadget at 100, 25 which contains the text "Click Me", and has a
  1223. Xgadget ID of 43.  makeboolgadget()  WILL  take care of making sure the
  1224. Xgadget is displayed, so you need not do anything after the return from the
  1225. Xfunction.  You should however keep track of the allocated gadgets so that
  1226. Xyou can properly free their allocated memory.
  1227. X
  1228. X    For the curious, this function calls the lower level function
  1229. Xcreate_boolgadget() with appropriate values.  It then calls AddGList() and
  1230. XRefreshGList() to cause the gadget to display.
  1231. X
  1232. XTODO : Really need to make the gadgets more 3d'ish.  They look kinda plain
  1233. X       now.
  1234. X
  1235. XBUGS : could be, but none that I've seen (fingers crossed)
  1236. X
  1237. XSEE ALSO : create_boolgadget(), killgadget(), makewindow(), getyn(),
  1238. X       getstring()
  1239. X
  1240. END_OF_FILE
  1241. if test 2662 -ne `wc -c <'doc/makeboolgadget.doc'`; then
  1242.     echo shar: \"'doc/makeboolgadget.doc'\" unpacked with wrong size!
  1243. fi
  1244. # end of 'doc/makeboolgadget.doc'
  1245. fi
  1246. if test -f 'doc/makescreen.doc' -a "${1}" != "-c" ; then 
  1247.   echo shar: Will not clobber existing file \"'doc/makescreen.doc'\"
  1248. else
  1249. echo shar: Extracting \"'doc/makescreen.doc'\" \(2593 characters\)
  1250. sed "s/^X//" >'doc/makescreen.doc' <<'END_OF_FILE'
  1251. XFUNCTION  makescreen()  -  Easily create a custom screen
  1252. X
  1253. X  struct Screen *makescreen(modes, depth)
  1254. X           int modes;
  1255. X           int depth;
  1256. X
  1257. X    This function will create a custom screen of the specified modes and
  1258. Xdepth for you.    makescreen() will return NULL if something couldn't be
  1259. Xallocated or created.  Check the return value to make sure you have a
  1260. Xvalid screen pointer.  Valid modes are defined in graphics/view.h.  The
  1261. Xmore common ones are :
  1262. X
  1263. X        LORES           -  open a 320x200 screen
  1264. X    HIRES        -  open a hires (640 pixels across) screen
  1265. X    LACE        -  make the screen interlace (400 vertical lines)
  1266. X    EXTRA_HALFBRITE -  specify extra half bright mode (64 colors)
  1267. X    HAM        -  make a HAM (hold and modify) 4096 color screen.
  1268. X
  1269. X    If you specify NULL for modes, you will get a standard 320x200 screen.
  1270. X
  1271. X    Some checking is done to make sure that you don't screw yourself.
  1272. XIf graphics.library and intuition.library aren't opened before you call
  1273. Xthis function, they WILL be opened for you.
  1274. X
  1275. X    If you specify a depth of greater than 2 (depth > 2), the bitmap data
  1276. Xyou need will be allocated.  However, the ExtData field of the screen
  1277. Xstructure will be used to hold some information needed for later when you
  1278. Xcall killscreen().  This is a warning that you should not use the
  1279. Xscreen->ExtData field, or if you do, you should save its value and put it
  1280. Xback BEFORE you call killscreen().
  1281. X
  1282. X    Also be advised that some programs illegally modify the
  1283. Xscreen->UserData field of your PRIVATE custom screen.  QMouse was caught
  1284. Xblatantly doing this horrendous crime (at least as far as I could tell).
  1285. XThis is definitely a bug in QMouse, but since I really like QMouse, I
  1286. Xchanged Ez.lib to use the screen->ExtData field.  BTW, you wanna talk about
  1287. Xa hard to find bug, try tracking that one down!
  1288. X
  1289. X    To open a HIRES 3 bitplane screen you would do the following :
  1290. X
  1291. X      struct Screen *screen;
  1292. X
  1293. X      screen = makescreen(HIRES, 3);
  1294. X      if (screen == NULL)
  1295. X    no_screen();
  1296. X
  1297. X    To open a LORES (320x200) 5 bitplane screen, do this :
  1298. X
  1299. X      struct Screen *screen;
  1300. X
  1301. X      screen = makescreen(LORES, 5);
  1302. X      if (screen == NULL)
  1303. X    no_screen();
  1304. X
  1305. X    To open a LORES, interlaced, extra half-brite screen of
  1306. X    6 bitplanes, do this :
  1307. X
  1308. X      struct Screen *screen;
  1309. X
  1310. X      screen = makescreen(LORES|LACE|EXTRA_HALFBRITE, 6);
  1311. X      if (screen == NULL)
  1312. X    no_screen();
  1313. X
  1314. X
  1315. XTODO  : maybe more error checking on the modes field.  Everything should be
  1316. X    covered however.  Probably should #define LORES 0 in lib.h so that
  1317. X    the calls to makescreen are more readable.
  1318. X
  1319. XBUGS  : None
  1320. X
  1321. XSEE ALSO : killscreen(screen);  makewindow();
  1322. X
  1323. X
  1324. X
  1325. X
  1326. END_OF_FILE
  1327. if test 2593 -ne `wc -c <'doc/makescreen.doc'`; then
  1328.     echo shar: \"'doc/makescreen.doc'\" unpacked with wrong size!
  1329. fi
  1330. # end of 'doc/makescreen.doc'
  1331. fi
  1332. if test -f 'doc/makewindow.doc' -a "${1}" != "-c" ; then 
  1333.   echo shar: Will not clobber existing file \"'doc/makewindow.doc'\"
  1334. else
  1335. echo shar: Extracting \"'doc/makewindow.doc'\" \(1855 characters\)
  1336. sed "s/^X//" >'doc/makewindow.doc' <<'END_OF_FILE'
  1337. XFUNCTION  makewindow()  -  Easily create an Intution window
  1338. X
  1339. X struct Window *makewindow(screen, leftedge, topedge, width, height)
  1340. X          struct Screen *screen;
  1341. X          int leftedge, topedge;
  1342. X          int width, height;
  1343. X
  1344. X
  1345. X    This function will open a standard Intuition window for you.  You
  1346. Xspecify a screen pointer if you would like this window to appear on a
  1347. Xcustom screen or NULL if you would like it to appear on the workbench.    The
  1348. Xleftedge, topedge, width, and height variables specify the new window's
  1349. Xdimensions. They are error checked for sanity.
  1350. X
  1351. X    The window that is opened has a Close Gadget, TitleBar, Depth Gadget,
  1352. Xand a Sizing Gadget.  The window is also SMART_REFRESH, therefore you
  1353. Xdon't have to worry about refreshing your display.  This is a very high
  1354. Xlevel routine, that doesn't give you much flexibility over the appearance
  1355. Xof the window, but quickly and painlessly gets you a window.
  1356. X
  1357. X    Since there is a Close Gadget on this window, you will receive
  1358. XIntuition messages (which you can safely ignore if you want).  However it
  1359. Xis better if you do check to see if the user has clicked the Close Gadget
  1360. Xin that window.  NOTE: the flags which this window is opened with will only
  1361. Xsend you a CLOSEWINDOW Intuition Message.  If you wish to receive other
  1362. Xwindow messages (like DISKINSERTED or something), you should use
  1363. XModifyIDCMP() to tell Intuition you want those messages.
  1364. X
  1365. X
  1366. X    Final note, if graphics.library and intuition.library haven't been
  1367. Xopened yet, this routine will open them for you.
  1368. X
  1369. X
  1370. X    This example opens a 200x100 window at 0, 0 on the workbench screen:
  1371. X
  1372. X       struct Window *window;
  1373. X
  1374. X       window = makewindow(NULL, 0,0, 200, 100);
  1375. X       if (window == NULL)
  1376. X     no_window()
  1377. X
  1378. X
  1379. X
  1380. XTODO : none at the moment.  Lets hope software rot doesn't set in.
  1381. X
  1382. XBUGS : none that I know of.
  1383. X
  1384. XSEE ALSO : killwindow(); makescreen(); killscreen();
  1385. X
  1386. X
  1387. END_OF_FILE
  1388. if test 1855 -ne `wc -c <'doc/makewindow.doc'`; then
  1389.     echo shar: \"'doc/makewindow.doc'\" unpacked with wrong size!
  1390. fi
  1391. # end of 'doc/makewindow.doc'
  1392. fi
  1393. if test -f 'doc/openlibs.doc' -a "${1}" != "-c" ; then 
  1394.   echo shar: Will not clobber existing file \"'doc/openlibs.doc'\"
  1395. else
  1396. echo shar: Extracting \"'doc/openlibs.doc'\" \(1890 characters\)
  1397. sed "s/^X//" >'doc/openlibs.doc' <<'END_OF_FILE'
  1398. XFUNCTION  openlibs()  -  Easily open any of several system libraries
  1399. X
  1400. X      openlibs( which_ones )
  1401. X        int which_ones;
  1402. X
  1403. X    This function takes an integer argument which specifies which libraries
  1404. Xyou would like to have opened for your program.  The libraries you can open
  1405. Xare:
  1406. X
  1407. X          GFX              : graphics.library
  1408. X          INTUI or INTUITION      : intuition.library
  1409. X          DFONT or DISKFONT       : diskfont.library
  1410. X          ARP              : arp.library
  1411. X          TRANSLATOR          : translator.library
  1412. X          REXX              : rexxsyslib.library
  1413. X
  1414. X
  1415. XThese values are simply numeric #define's, which can be or'ed together.
  1416. X
  1417. X
  1418. XTo open the graphics.library, you would simply do the following:
  1419. X
  1420. X  success = openlibs(GFX);
  1421. X  if (success == NULL)
  1422. X    deal_with_failure();
  1423. X
  1424. XYou can open multiple libraries with a single call by doing the following:
  1425. X
  1426. X  success = openlibs(GFX | ARP | INTUITION | DISKFONT);
  1427. X  if (success == NULL)
  1428. X    deal_with_failure();
  1429. X
  1430. X    The above opens the graphics.library, arp.library, intuition.library,
  1431. Xand diskfont.library all in a single call.
  1432. X
  1433. X    If any of the libraries fail to open, openlibs() will print an error
  1434. Xmessage to your output stream saying which library didn't open and it
  1435. Xwill return NULL.
  1436. X
  1437. X    openlibs() will close any libraries it opened if a succesive
  1438. XOpenLibrary() call fails.  Therefore, you don't have to worry about opened
  1439. Xlibraries sitting around and never being closed.  This is to say that if
  1440. Xyou ask for GFX | INTUI | ARP, and graphics.library and intuition.library
  1441. Xopen, but arp.library doesn't, graphics and intuition will be closed down
  1442. Xfor you and NULL returned.
  1443. X
  1444. X
  1445. X
  1446. XTODO : Shouldn't be much else.  Maybe a way to add more libraries that
  1447. X       can be opened without having to recompile.  Possibly a name/variable
  1448. X       combo....
  1449. X
  1450. XBUGS :    can only support 32 different libraries to be opened.  That's not
  1451. X    too much of a restriction, but it still is one.
  1452. X
  1453. X
  1454. END_OF_FILE
  1455. if test 1890 -ne `wc -c <'doc/openlibs.doc'`; then
  1456.     echo shar: \"'doc/openlibs.doc'\" unpacked with wrong size!
  1457. fi
  1458. # end of 'doc/openlibs.doc'
  1459. fi
  1460. if test -f 'ezlib.h' -a "${1}" != "-c" ; then 
  1461.   echo shar: Will not clobber existing file \"'ezlib.h'\"
  1462. else
  1463. echo shar: Extracting \"'ezlib.h'\" \(1698 characters\)
  1464. sed "s/^X//" >'ezlib.h' <<'END_OF_FILE'
  1465. X/* Header file for use with ez.lib */
  1466. X
  1467. X#define GFX        0x001
  1468. X#define INTUI        0x002
  1469. X#define INTUITION   0x002
  1470. X#define ARP        0x004
  1471. X#define DFONT        0x008
  1472. X#define DISKFONT    0x008
  1473. X#define TRANSLATOR  0x010
  1474. X#define ICONBASE    0x080
  1475. X#define REXX        0x100
  1476. X
  1477. X#define MSG(a) (Write(Output(), a, strlen(a)))
  1478. X
  1479. Xstruct Screen    *makescreen();
  1480. Xstruct Window    *makewindow();
  1481. Xstruct Window    *createwindow();
  1482. Xstruct Gadget    *makeboolgadget();
  1483. Xstruct Gadget    *create_boolgadget();
  1484. Xstruct BitMap    *getbitmap();
  1485. Xstruct TextFont *getfont();
  1486. Xchar        *getstring();
  1487. X
  1488. X/* these functions (and closelibs()) should properly be void, however
  1489. X * manx 3.6a seems to think I'm redeclaring the function when a function
  1490. X * is defined here as void.  As int it works fine....
  1491. X */
  1492. Xint killscreen();
  1493. Xint killwindow();
  1494. Xint free_bitmap();
  1495. Xint getyn();
  1496. Xint openlibs();
  1497. Xint closelibs();
  1498. X
  1499. X#define setcolor(screen, num, color) (SetRGB4(&screen->ViewPort, num, (0x0f00&color)>>8, (0x00f0&color)>>4, (0x000f&color) ))
  1500. X#define BLACK      0x0000
  1501. X#define WHITE      0x0fff
  1502. X#define RED      0x0f00
  1503. X#define GREEN      0x00f0
  1504. X#define BLUE      0x000f
  1505. X#define YELLOW      0x0ff0
  1506. X#define CYAN      0x00ff
  1507. X#define PINK      0x0f09
  1508. X#define PURPLE      0x0f0f
  1509. X#define GREY0      0x0ccc
  1510. X#define GREY      0x0aaa
  1511. X#define GREY1      0x0888
  1512. X#define GREY2      0x0666
  1513. X#define GREY3      0x0444
  1514. X#define GOLD      0x0ea1
  1515. X#define ORANGE      0x0f70
  1516. X#define INDIGO      0x070e
  1517. X
  1518. X#define initgfx()  (openlibs(GFX))
  1519. X#define closegfx() (closelibs())
  1520. X
  1521. X#define Print(rp, b) (Text(rp, b, strlen(b)))
  1522. X#define Line(rp, a, b, c, d) { Move(rp, a, b); Draw(rp, c, d); }
  1523. X#define Circle(rp, x, y, rad) (DrawEllipse(rp, x, y, rad, rad))
  1524. X
  1525. X/* just a quickie to make calls to makescreen() a little more clear */
  1526. X#define LORES 0x0000
  1527. X
  1528. END_OF_FILE
  1529. if test 1698 -ne `wc -c <'ezlib.h'`; then
  1530.     echo shar: \"'ezlib.h'\" unpacked with wrong size!
  1531. fi
  1532. # end of 'ezlib.h'
  1533. fi
  1534. if test ! -d 'src' ; then
  1535.     echo shar: Creating directory \"'src'\"
  1536.     mkdir 'src'
  1537. fi
  1538. if test -f 'src/ezlib.h' -a "${1}" != "-c" ; then 
  1539.   echo shar: Will not clobber existing file \"'src/ezlib.h'\"
  1540. else
  1541. echo shar: Extracting \"'src/ezlib.h'\" \(1659 characters\)
  1542. sed "s/^X//" >'src/ezlib.h' <<'END_OF_FILE'
  1543. X#define GFX        0x001
  1544. X#define INTUI        0x002
  1545. X#define INTUITION   0x002
  1546. X#define ARP        0x004
  1547. X#define DFONT        0x008
  1548. X#define DISKFONT    0x008
  1549. X#define TRANSLATOR  0x010
  1550. X#define ICONBASE    0x080
  1551. X#define REXX        0x100
  1552. X
  1553. X#define MSG(a) (Write(Output(), a, strlen(a)))
  1554. X
  1555. Xstruct Screen    *makescreen();
  1556. Xstruct Window    *makewindow();
  1557. Xstruct Window    *createwindow();
  1558. Xstruct Gadget    *makeboolgadget();
  1559. Xstruct Gadget    *create_boolgadget();
  1560. Xstruct BitMap    *getbitmap();
  1561. Xstruct TextFont *getfont();
  1562. Xchar        *getstring();
  1563. X
  1564. X/* these functions (and closelibs()) should properly be void, however
  1565. X * manx 3.6a seems to think I'm redeclaring the function when a function
  1566. X * is defined here as void.  As int it works fine....
  1567. X */
  1568. Xint killscreen();
  1569. Xint killwindow();
  1570. Xint free_bitmap();
  1571. Xint getyn();
  1572. Xint openlibs();
  1573. Xint closelibs();
  1574. X
  1575. X#define setcolor(screen, num, color) (SetRGB4(&screen->ViewPort, num, (0x0f00&color)>>8, (0x00f0&color)>>4, (0x000f&color) ))
  1576. X#define BLACK      0x0000
  1577. X#define WHITE      0x0fff
  1578. X#define RED      0x0f00
  1579. X#define GREEN      0x00f0
  1580. X#define BLUE      0x000f
  1581. X#define YELLOW      0x0ff0
  1582. X#define CYAN      0x00ff
  1583. X#define PINK      0x0f09
  1584. X#define PURPLE      0x0f0f
  1585. X#define GREY0      0x0ccc
  1586. X#define GREY      0x0aaa
  1587. X#define GREY1      0x0888
  1588. X#define GREY2      0x0666
  1589. X#define GREY3      0x0444
  1590. X#define GOLD      0x0ea1
  1591. X#define ORANGE      0x0f70
  1592. X#define INDIGO      0x070e
  1593. X
  1594. X#define initgfx()  (openlibs(GFX))
  1595. X#define closegfx() (closelibs())
  1596. X
  1597. X#define Print(rp, b) (Text(rp, b, strlen(b)))
  1598. X#define Line(rp, a, b, c, d) { Move(rp, a, b); Draw(rp, c, d); }
  1599. X#define Circle(rp, x, y, rad) (DrawEllipse(rp, x, y, rad, rad))
  1600. X
  1601. X/* just a quickie to make calls to makescreen() a little more clear */
  1602. X#define LORES 0x0000
  1603. X
  1604. END_OF_FILE
  1605. if test 1659 -ne `wc -c <'src/ezlib.h'`; then
  1606.     echo shar: \"'src/ezlib.h'\" unpacked with wrong size!
  1607. fi
  1608. # end of 'src/ezlib.h'
  1609. fi
  1610. if test -f 'src/gadg.c' -a "${1}" != "-c" ; then 
  1611.   echo shar: Will not clobber existing file \"'src/gadg.c'\"
  1612. else
  1613. echo shar: Extracting \"'src/gadg.c'\" \(989 characters\)
  1614. sed "s/^X//" >'src/gadg.c' <<'END_OF_FILE'
  1615. X#include "ezlib.h"
  1616. X
  1617. Xmain()
  1618. X{
  1619. X struct Window *win;
  1620. X struct Gadget *test, *test2;
  1621. X struct IntuiMessage *msg, *GetMsg();
  1622. X int id;
  1623. X
  1624. X win = makewindow(NULL, 0, 0, 300, 100);
  1625. X if (win == NULL)
  1626. X   exit(10);
  1627. X
  1628. X test = makeboolgadget(win, 100, 25, "Hey there!", 43);
  1629. X test2 = create_boolgadget(100, 50, GADGHBOX, RELVERIFY, "X", 44);
  1630. X AddGadget(win, test2, (USHORT)~0);
  1631. X RefreshGadgets(test2, win, NULL);
  1632. X
  1633. X ModifyIDCMP(win, CLOSEWINDOW|GADGETUP);
  1634. X
  1635. X while(1) {
  1636. X   WaitPort(win->UserPort);
  1637. X   msg = GetMsg(win->UserPort);
  1638. X
  1639. X   switch(msg->Class){
  1640. X     case GADGETUP  : id = ((struct Gadget*)msg->IAddress)->GadgetID;
  1641. X              if (id == 43){
  1642. X            Move(win->RPort, 50, 50);
  1643. X            Print(win->RPort, "Got a click!");
  1644. X               }
  1645. X              else if (id == 44) {
  1646. X            Move(win->RPort, 80, 20);
  1647. X            Print(win->RPort, "Hehehehehehee");
  1648. X               }
  1649. X
  1650. X              break;
  1651. X
  1652. X     case CLOSEWINDOW : killgadget(win, test);
  1653. X            killgadget(win, test2);
  1654. X            killwindow(win);
  1655. X            exit(0);
  1656. X
  1657. X     default : break;
  1658. X    }
  1659. X   ReplyMsg(msg);
  1660. X }
  1661. X}
  1662. X
  1663. END_OF_FILE
  1664. if test 989 -ne `wc -c <'src/gadg.c'`; then
  1665.     echo shar: \"'src/gadg.c'\" unpacked with wrong size!
  1666. fi
  1667. # end of 'src/gadg.c'
  1668. fi
  1669. if test -f 'src/gadget.c' -a "${1}" != "-c" ; then 
  1670.   echo shar: Will not clobber existing file \"'src/gadget.c'\"
  1671. else
  1672. echo shar: Extracting \"'src/gadget.c'\" \(3247 characters\)
  1673. sed "s/^X//" >'src/gadget.c' <<'END_OF_FILE'
  1674. X#include "ezlib.h"
  1675. X
  1676. Xextern struct GfxBase *GfxBase;
  1677. Xvoid *AllocMem();
  1678. X
  1679. X/* These functions deal with gadgets and adding them to your window */
  1680. X
  1681. Xstruct Gadget *create_boolgadget(l_edge, t_edge, flags, activation, text, id)
  1682. X  SHORT l_edge, t_edge;
  1683. X  USHORT flags, activation;
  1684. X  UBYTE *text;
  1685. X  USHORT id;
  1686. X{
  1687. X struct Gadget      *gadg   = NULL;
  1688. X struct IntuiText *i_text = NULL;
  1689. X struct Border      *bord   = NULL;
  1690. X int i,j;
  1691. X
  1692. X if ( (flags & GADGHIMAGE) != NULL)
  1693. X   return NULL;
  1694. X
  1695. X if ( (flags & GADGHBOX) == NULL && (flags & GADGHCOMP) == NULL)
  1696. X    flags |= GADGHCOMP;
  1697. X
  1698. X /* get everything allocated first, and fail if any of this does */
  1699. X gadg    = (struct Gadget *)   AllocMem(sizeof(struct Gadget),    MEMF_CLEAR);
  1700. X i_text = (struct IntuiText*) AllocMem(sizeof(struct IntuiText), MEMF_CLEAR);
  1701. X bord    = (struct Border *)   AllocMem(sizeof(struct Border),    MEMF_CLEAR);
  1702. X if (bord)
  1703. X   bord->XY  = (SHORT *)AllocMem(10 * sizeof(SHORT), 0L);
  1704. X
  1705. X if (gadg == NULL || i_text == NULL || bord == NULL || bord->XY == NULL){
  1706. X   if (gadg)
  1707. X     FreeMem(gadg, sizeof(struct Gadget));
  1708. X   if (i_text)
  1709. X     FreeMem(i_text, sizeof(struct IntuiText));
  1710. X   if (bord) {
  1711. X     if (bord->XY)
  1712. X       FreeMem(bord->XY, 10*sizeof(SHORT));
  1713. X     FreeMem(bord, sizeof(struct Border));
  1714. X   }
  1715. X   return NULL;
  1716. X }
  1717. X
  1718. X /* do some generic setup stuff */
  1719. X gadg->LeftEdge   = l_edge;        gadg->TopEdge      = t_edge;
  1720. X gadg->Flags      = flags;        gadg->Activation   = activation;
  1721. X gadg->GadgetID   = id;         gadg->GadgetType   = BOOLGADGET;
  1722. X gadg->GadgetText = i_text;        gadg->GadgetRender = (APTR)bord;
  1723. X
  1724. X /* fill in the Itext struct */
  1725. X i_text->FrontPen   =    2;        i_text->DrawMode   =  JAM1;
  1726. X i_text->LeftEdge   =    10;        i_text->TopEdge    =  3;
  1727. X i_text->IText        =    text;
  1728. X
  1729. X /* calculate where the box should be and fill in the border struct */
  1730. X bord->LeftEdge    = -1;        bord->TopEdge     = -1;
  1731. X bord->FrontPen    = 1;         bord->BackPen     = 0;
  1732. X bord->DrawMode    = JAM1;        bord->Count       = 5;
  1733. X
  1734. X /* here we calculate where everything should go... */
  1735. X i = IntuiTextLength(i_text) + 22;
  1736. X if (i < 30)
  1737. X   i = 30;
  1738. X j = GfxBase->DefaultFont->tf_YSize + 6;
  1739. X
  1740. X bord->XY[0] = 0;            bord->XY[1]  = 0;
  1741. X bord->XY[2] = i;            bord->XY[3]  = 0;
  1742. X bord->XY[4] = i;            bord->XY[5]  = j;
  1743. X bord->XY[6] = 0;            bord->XY[7]  = j;
  1744. X bord->XY[8] = 0;            bord->XY[9]  = 0;
  1745. X gadg->Width = i - 1;            gadg->Height = j - 1;
  1746. X
  1747. X return gadg;
  1748. X}
  1749. X
  1750. X
  1751. Xstruct Gadget *makeboolgadget(window, l_edge, t_edge, text, id)
  1752. X struct Window *window;
  1753. X SHORT l_edge, t_edge;
  1754. X UBYTE *text;
  1755. X USHORT id;
  1756. X{
  1757. X USHORT flags, activation;
  1758. X struct Gadget *gadg;
  1759. X
  1760. X flags        = GADGHCOMP;
  1761. X activation = RELVERIFY;
  1762. X
  1763. X gadg = create_boolgadget(l_edge, t_edge, flags, activation, text, id);
  1764. X if (gadg == NULL)
  1765. X   return NULL;
  1766. X
  1767. X AddGadget(window, gadg, (USHORT)~0);
  1768. X RefreshGList(gadg, window, NULL, 1);
  1769. X
  1770. X return gadg;
  1771. X}
  1772. X
  1773. X
  1774. X/* this routine will free up the gadget for you */
  1775. X
  1776. Xkillgadget(win, gadg)
  1777. X  struct Window *win;
  1778. X  struct Gadget *gadg;
  1779. X{
  1780. X int i;
  1781. X
  1782. X RemoveGadget(win, gadg);
  1783. X RefreshGadgets( win->FirstGadget, win, NULL);
  1784. X
  1785. X FreeMem(((struct Border *)gadg->GadgetRender)->XY, 10*sizeof(SHORT));
  1786. X FreeMem(gadg->GadgetRender, sizeof(struct Border));
  1787. X FreeMem(gadg->GadgetText, sizeof(struct IntuiText));
  1788. X FreeMem(gadg, sizeof(struct Gadget));
  1789. X}
  1790. X
  1791. END_OF_FILE
  1792. if test 3247 -ne `wc -c <'src/gadget.c'`; then
  1793.     echo shar: \"'src/gadget.c'\" unpacked with wrong size!
  1794. fi
  1795. # end of 'src/gadget.c'
  1796. fi
  1797. if test -f 'src/getfont.c' -a "${1}" != "-c" ; then 
  1798.   echo shar: Will not clobber existing file \"'src/getfont.c'\"
  1799. else
  1800. echo shar: Extracting \"'src/getfont.c'\" \(1456 characters\)
  1801. sed "s/^X//" >'src/getfont.c' <<'END_OF_FILE'
  1802. X/*    This file contains a routine to open a disk based font.  It returns
  1803. X * a pointer to a TextFont structure, which if isn't NULL  can be immediatly
  1804. X * SetFont()'ed into your rastport.
  1805. X *
  1806. X *    It tries to be smart about font names taking care if you didn't append
  1807. X * a ".font" to the font name.
  1808. X */
  1809. X
  1810. X#include "ezlib.h"
  1811. X
  1812. Xextern struct Library *DiskfontBase;
  1813. X
  1814. Xvoid *AllocMem();
  1815. X
  1816. Xstruct TextFont *getfont( name, size )
  1817. X char *name;
  1818. X int size;
  1819. X{
  1820. X  struct Library *OpenLibrary();
  1821. X  struct TextFont *OpenDiskFont();
  1822. X  struct TextFont *txfont;
  1823. X  struct TextAttr txattr;
  1824. X  LONG len;
  1825. X  char *fontname, *test, *ext = ".font", *rindex();
  1826. X  UBYTE pre_opened=FALSE;
  1827. X
  1828. X  if (DiskfontBase < 100)
  1829. X    DiskfontBase = (struct Library *)OpenLibrary("diskfont.library",0L);
  1830. X  else
  1831. X    pre_opened = TRUE;
  1832. X
  1833. X  if (DiskfontBase == NULL)    /* just a quickie failsafe....  */
  1834. X    return NULL;
  1835. X
  1836. X  len = strlen(name) + 6;
  1837. X  fontname = (char *)AllocMem(len, 0L);
  1838. X  if (fontname == NULL)
  1839. X    return NULL;
  1840. X
  1841. X  strcpy(fontname, name);
  1842. X  test = rindex(fontname, '.');
  1843. X  /* if true, then they are not equal */
  1844. X  if (test == NULL || strcmp(test, ext))
  1845. X    strcat(fontname, ext);
  1846. X
  1847. X  txattr.ta_Name =  (STRPTR)fontname;
  1848. X  txattr.ta_YSize = (UWORD)size;
  1849. X  txattr.ta_Style = FS_NORMAL;
  1850. X  txattr.ta_Flags = FPF_DISKFONT;
  1851. X
  1852. X  txfont = OpenDiskFont(&txattr);
  1853. X
  1854. X  FreeMem(fontname, len);
  1855. X  if (pre_opened == FALSE) {
  1856. X    CloseLibrary(DiskfontBase);
  1857. X    DiskfontBase = NULL;
  1858. X   }
  1859. X  return txfont;
  1860. X}
  1861. X
  1862. END_OF_FILE
  1863. if test 1456 -ne `wc -c <'src/getfont.c'`; then
  1864.     echo shar: \"'src/getfont.c'\" unpacked with wrong size!
  1865. fi
  1866. # end of 'src/getfont.c'
  1867. fi
  1868. if test -f 'src/getyn.c' -a "${1}" != "-c" ; then 
  1869.   echo shar: Will not clobber existing file \"'src/getyn.c'\"
  1870. else
  1871. echo shar: Extracting \"'src/getyn.c'\" \(1418 characters\)
  1872. sed "s/^X//" >'src/getyn.c' <<'END_OF_FILE'
  1873. X/*    This function will get a yes or no answer from a users.  It tries
  1874. X * to be smart about how it opens the autorequest().
  1875. X *
  1876. X *    Also you should know that this some of this code came from the DME
  1877. X * source code of the same function.  However I have changed it a fair
  1878. X * amount....
  1879. X */
  1880. X
  1881. X#include "ezlib.h"
  1882. X
  1883. Xvoid *AllocMem();
  1884. X
  1885. Xgetyn(win, text)
  1886. Xstruct Window *win;
  1887. Xchar *text;
  1888. X{
  1889. X    int result, width;
  1890. X    struct IntuiText *body, *pos, *neg;
  1891. X
  1892. X    if (win <= 100)       /* quick sanity check */
  1893. X      return NULL;
  1894. X
  1895. X    /* this is a sneaky way to only have to do a single AllocMem instead
  1896. X     * of 3 seperate ones (each with error checking).
  1897. X     */
  1898. X    body = (struct IntuiText *)AllocMem( (3*sizeof(struct IntuiText)), MEMF_CLEAR);
  1899. X    if (body == NULL)
  1900. X      return NULL;
  1901. X
  1902. X    pos = &body[1]; neg = &body[2];
  1903. X
  1904. X    body->BackPen  = pos->BackPen  = neg->BackPen  = 1;
  1905. X    body->DrawMode = pos->DrawMode = neg->DrawMode = AUTODRAWMODE;
  1906. X    body->LeftEdge = 10;
  1907. X    body->TopEdge  = 12;
  1908. X    body->IText    = (UBYTE *)text;
  1909. X    pos->LeftEdge  = pos->TopEdge  = AUTOTOPEDGE;
  1910. X    pos->IText       = (UBYTE *)" OK ";
  1911. X    neg->LeftEdge  = neg->TopEdge  = AUTOTOPEDGE;
  1912. X    neg->IText       = (UBYTE *)" CANCEL";
  1913. X
  1914. X    width = IntuiTextLength(body) + 50;
  1915. X    if (width < 150)
  1916. X      width = 225;
  1917. X    result = AutoRequest(win, body, pos, neg, 0, 0, width, 58);
  1918. X    FreeMem(body, (3*sizeof(struct IntuiText)));
  1919. X
  1920. X    return(result);
  1921. X}
  1922. X
  1923. END_OF_FILE
  1924. if test 1418 -ne `wc -c <'src/getyn.c'`; then
  1925.     echo shar: \"'src/getyn.c'\" unpacked with wrong size!
  1926. fi
  1927. # end of 'src/getyn.c'
  1928. fi
  1929. if test ! -d 'src/include' ; then
  1930.     echo shar: Creating directory \"'src/include'\"
  1931.     mkdir 'src/include'
  1932. fi
  1933. if test -f 'src/include/includes.h' -a "${1}" != "-c" ; then 
  1934.   echo shar: Will not clobber existing file \"'src/include/includes.h'\"
  1935. else
  1936. echo shar: Extracting \"'src/include/includes.h'\" \(629 characters\)
  1937. sed "s/^X//" >'src/include/includes.h' <<'END_OF_FILE'
  1938. X#include <ctype.h>
  1939. X#include <exec/exec.h>
  1940. X#include <libraries/dos.h>
  1941. X#include <libraries/dosextens.h>
  1942. X/****************  NOT NEEDED #include <libraries/arpbase.h> *************/
  1943. X#include <graphics/rastport.h>
  1944. X#include <graphics/text.h>
  1945. X#include <graphics/view.h>
  1946. X#include <graphics/gfx.h>
  1947. X#include <graphics/gfxbase.h>
  1948. X#include <graphics/gfxmacros.h>
  1949. X#include <intuition/intuition.h>
  1950. X#include <intuition/intuitionbase.h>
  1951. X#include <intuition/preferences.h>
  1952. X#include <intuition/screens.h>
  1953. X/*****************   NOT NEEDED  #include <arpfunctions.h>****************/
  1954. X#include <workbench/workbench.h>
  1955. X#include <workbench/startup.h>
  1956. X
  1957. X
  1958. END_OF_FILE
  1959. if test 629 -ne `wc -c <'src/include/includes.h'`; then
  1960.     echo shar: \"'src/include/includes.h'\" unpacked with wrong size!
  1961. fi
  1962. # end of 'src/include/includes.h'
  1963. fi
  1964. if test -f 'src/makefile' -a "${1}" != "-c" ; then 
  1965.   echo shar: Will not clobber existing file \"'src/makefile'\"
  1966. else
  1967. echo shar: Extracting \"'src/makefile'\" \(1411 characters\)
  1968. sed "s/^X//" >'src/makefile' <<'END_OF_FILE'
  1969. X# this is a somewhat stupid makefile.  I still haven't learned the
  1970. X# subtleties of the .c.o rules... sigh
  1971. X#
  1972. X# This will compile and make the library.  I make use of a pre-compiled
  1973. X# header file as it makes compile times *much* faster.    Everything should
  1974. X# work as is if you have to rebuild the library (at least I hope so).
  1975. X#
  1976. X# Oh BTW, the demo that is in the directory above this one is created in
  1977. X# this makefile.  This is to test out the library, and if you make changes
  1978. X# you should make sure that the demo still works
  1979. X#
  1980. X
  1981. X# header.h is actually the precompiled header file
  1982. XCFLAGS = +L +Iinclude/header.h
  1983. X
  1984. XOBJS= getstring.o getfont.o getyn.o gadget.o window.o screen.o openlibs.o
  1985. X
  1986. Xall : demo ez.lib include/header.h
  1987. X
  1988. Xinclude/header.h : include/includes.h
  1989. X         cc +L +Hinclude/header.h includes.h
  1990. X
  1991. Xdemo : ez.lib demo.o
  1992. X    ln -o demo demo.o ez.lib -lc
  1993. X
  1994. Xdemo.o       : demo.c
  1995. X       cc $(CFLAGS) demo.c
  1996. X
  1997. Xez.lib : $(OBJS)
  1998. X     lb ez $(OBJS)
  1999. X
  2000. Xopenlibs.o : openlibs.c ezlib.h
  2001. X       cc $(CFLAGS) openlibs.c
  2002. X
  2003. Xscreen.o  : screen.c ezlib.h
  2004. X       cc $(CFLAGS) screen.c
  2005. X
  2006. Xwindow.o  : window.c ezlib.h
  2007. X       cc $(CFLAGS) window.c
  2008. X
  2009. Xgadget.o  : gadget.c ezlib.h
  2010. X       cc $(CFLAGS) gadget.c
  2011. X
  2012. Xgetyn.o    : getyn.c  ezlib.h
  2013. X       cc $(CFLAGS) getyn.c
  2014. X
  2015. Xgetfilename.o : getfilename.c ezlib.h
  2016. X          cc $(CFLAGS) getfilename.c
  2017. X
  2018. Xgetfont.o  : getfont.c ezlib.h
  2019. X       cc $(CFLAGS) getfont.c
  2020. X
  2021. Xgetstring.o   : getstring.c  ezlib.h
  2022. X       cc $(CFLAGS) getstring.c
  2023. X
  2024. END_OF_FILE
  2025. if test 1411 -ne `wc -c <'src/makefile'`; then
  2026.     echo shar: \"'src/makefile'\" unpacked with wrong size!
  2027. fi
  2028. # end of 'src/makefile'
  2029. fi
  2030. if test -f 'src/openlibs.c' -a "${1}" != "-c" ; then 
  2031.   echo shar: Will not clobber existing file \"'src/openlibs.c'\"
  2032. else
  2033. echo shar: Extracting \"'src/openlibs.c'\" \(2268 characters\)
  2034. sed "s/^X//" >'src/openlibs.c' <<'END_OF_FILE'
  2035. X/*    This file contains the routines for opening and closing libraries.
  2036. X * Notice that all the library bases are defined here.    You can access
  2037. X * them in your code if you wish, but they are defined here.
  2038. X *
  2039. X *    Oh, it *is* important that they be initialized to zero.
  2040. X */
  2041. X
  2042. X#include "ezlib.h"
  2043. X
  2044. Xstruct GfxBase         *GfxBase         = NULL;
  2045. Xstruct IntuitionBase *IntuitionBase  = NULL;
  2046. Xstruct Library         *DiskfontBase   = NULL;
  2047. Xstruct ArpBase         *ArpBase         = NULL;
  2048. Xstruct Library         *TranslatorBase = NULL;
  2049. Xstruct RxsLib         *RexxSysBase    = NULL;
  2050. Xvoid *OpenLibrary();
  2051. X
  2052. Xopenlibs( which_ones )
  2053. X register int which_ones;
  2054. X{
  2055. X register int errs = NULL;
  2056. X
  2057. X if (which_ones & GFX)
  2058. X   if ( (GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0L)) == NULL)
  2059. X    {  MSG("No Graphics.library.\n"); errs = 1; }
  2060. X
  2061. X if (which_ones & INTUI)
  2062. X   if ( (IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0L)) == NULL)
  2063. X    {  MSG("No Intuition.library.\n"); errs = 1; }
  2064. X
  2065. X if (which_ones & ARP)
  2066. X   if ( (ArpBase = (struct ArpBase *)OpenLibrary("arp.library", 34)) == NULL)
  2067. X    { MSG("No Arp.library in your LIBS directory.\n");errs = 1; }
  2068. X
  2069. X if (which_ones & DISKFONT)
  2070. X   if ( (DiskfontBase = (struct Library *)OpenLibrary("diskfont.library", 0L)) == NULL)
  2071. X    { MSG("No Diskfont.library in your LIBS: directory.\n"); errs = 1; }
  2072. X
  2073. X if (which_ones & TRANSLATOR)
  2074. X   if ( (TranslatorBase = (struct Library *)OpenLibrary("translator.library", 0L)) == NULL)
  2075. X    { MSG("No Translator.library in your LIBS: directory.\n"); errs = 1; }
  2076. X
  2077. X if (which_ones & REXX)
  2078. X   if ( (RexxSysBase = (struct RxsLib *)OpenLibrary("rexxsyslib.library", 0L)) == NULL)
  2079. X    { MSG("No rexxsyslib.library in your LIBS: directory.\n"); errs = 1; }
  2080. X
  2081. X if ( errs )
  2082. X   { closelibs(); return NULL; }
  2083. X
  2084. X return 1;
  2085. X}
  2086. X
  2087. Xcloselibs()
  2088. X{
  2089. X if (DiskfontBase > 100)
  2090. X  { CloseLibrary(DiskfontBase); DiskfontBase = NULL; }
  2091. X
  2092. X if (ArpBase > 100)
  2093. X  { CloseLibrary(ArpBase); ArpBase = NULL; }
  2094. X
  2095. X if (IntuitionBase > 100)
  2096. X  { CloseLibrary(IntuitionBase); IntuitionBase = NULL; }
  2097. X
  2098. X if (GfxBase > 100)
  2099. X  { CloseLibrary(GfxBase); GfxBase = NULL; }
  2100. X
  2101. X if (TranslatorBase > 100)
  2102. X  { CloseLibrary(TranslatorBase); TranslatorBase = NULL; }
  2103. X
  2104. X if (RexxSysBase > 100)
  2105. X  { CloseLibrary(RexxSysBase); RexxSysBase = NULL; }
  2106. X}
  2107. X
  2108. END_OF_FILE
  2109. if test 2268 -ne `wc -c <'src/openlibs.c'`; then
  2110.     echo shar: \"'src/openlibs.c'\" unpacked with wrong size!
  2111. fi
  2112. # end of 'src/openlibs.c'
  2113. fi
  2114. if test -f 'src/window.c' -a "${1}" != "-c" ; then 
  2115.   echo shar: Will not clobber existing file \"'src/window.c'\"
  2116. else
  2117. echo shar: Extracting \"'src/window.c'\" \(3360 characters\)
  2118. sed "s/^X//" >'src/window.c' <<'END_OF_FILE'
  2119. X#include "ezlib.h"
  2120. X
  2121. Xextern struct GfxBase *GfxBase;
  2122. Xextern struct IntuitionBase *IntuitionBase;
  2123. Xextern int openlibs();
  2124. Xvoid *AllocMem();
  2125. X
  2126. X
  2127. Xstruct Window *createwindow(screen, flags, idcmp, leftedge, topedge, width, height)
  2128. X struct Screen *screen;
  2129. X ULONG flags, idcmp;
  2130. X int leftedge, topedge, width, height;
  2131. X{
  2132. X struct Window *OpenWindow();
  2133. X int wb_height;
  2134. X struct NewWindow *tempwin;
  2135. X struct Window *win;
  2136. X
  2137. X /* some sanity checking - short and fast */
  2138. X if(GfxBase == NULL || IntuitionBase == NULL)
  2139. X  if ( openlibs(GFX | INTUITION) == NULL)
  2140. X    return NULL;
  2141. X
  2142. X tempwin = (struct NewWindow *)AllocMem(sizeof(struct NewWindow), MEMF_CLEAR);
  2143. X if (tempwin == NULL)
  2144. X   return NULL;
  2145. X
  2146. X if (width < 0)                            /* more checking */
  2147. X   width = GfxBase->NormalDisplayColumns;
  2148. X if (height < 0)
  2149. X    height = 1500;
  2150. X
  2151. X tempwin->Flags    = flags;           tempwin->IDCMPFlags = idcmp;
  2152. X tempwin->LeftEdge = (SHORT)leftedge;  tempwin->Width      = (SHORT)width;
  2153. X tempwin->TopEdge  = (SHORT)topedge;   tempwin->Height     = (SHORT)height;
  2154. X tempwin->MinWidth = 60;           tempwin->MinHeight  = 30;
  2155. X tempwin->DetailPen= -1;           tempwin->BlockPen   = -1;
  2156. X tempwin->Type       = WBENCHSCREEN;
  2157. X tempwin->Screen = screen;    /* if it's null that's o.k. too */
  2158. X
  2159. X /* if user has a custom screen, open up on that screen */
  2160. X if (screen) {
  2161. X   tempwin->Type = CUSTOMSCREEN;
  2162. X   if (leftedge + width > screen->Width)
  2163. X     tempwin->Width = (screen->Width - leftedge);
  2164. X
  2165. X   if (topedge + height > screen->Height)
  2166. X     tempwin->Height = (screen->Height - topedge);
  2167. X  }
  2168. X else {
  2169. X   if (leftedge+width > GfxBase->NormalDisplayColumns)
  2170. X     tempwin->Width = (GfxBase->NormalDisplayColumns - leftedge);
  2171. X
  2172. X   /* gotta make sure to check for interlace */
  2173. X   wb_height = (GfxBase->NormalDisplayRows * (1 + laced_wb()) );
  2174. X   if (topedge + height > wb_height )
  2175. X     tempwin->Height = wb_height - topedge;
  2176. X  }
  2177. X
  2178. X win = OpenWindow(tempwin);
  2179. X
  2180. X FreeMem(tempwin, sizeof(struct NewWindow));
  2181. X return win;
  2182. X}   /* end of makewindow() */
  2183. X
  2184. X
  2185. X
  2186. X/* return TRUE (1) if wb screen is interlaced otherwise,
  2187. X * we return FALSE (0) if it is NOT interlaced
  2188. X */
  2189. Xlaced_wb()
  2190. X{
  2191. X struct Preferences prefs;
  2192. X
  2193. X GetPrefs(&prefs, sizeof(struct Preferences));
  2194. X if (prefs.LaceWB)
  2195. X   return 1;
  2196. X else
  2197. X   return 0;
  2198. X}  /*  end of laced_wb()  */
  2199. X
  2200. X
  2201. Xkillwindow(window)
  2202. X register struct Window *window;
  2203. X{
  2204. X register struct IntuiMessage *msg, *GetMsg();
  2205. X
  2206. X if (window < 100)
  2207. X   return;
  2208. X
  2209. X /* make sure this is NULL if you have already cleared out your menus. */
  2210. X if (window->MenuStrip != NULL)
  2211. X   ClearMenuStrip(window);
  2212. X
  2213. X /* make sure there aren't any junk messages hanging here */
  2214. X while(window->UserPort != NULL && (msg = GetMsg(window->UserPort)) != NULL )
  2215. X   ReplyMsg(msg);
  2216. X
  2217. X /* then just close the window */
  2218. X CloseWindow(window);
  2219. X}
  2220. X
  2221. X/* this routine will make your standard Intuition Window.  It creates
  2222. X * a window with all the standard system gadgets on it, and makes it
  2223. X * the appropriate size (with sanity checking)
  2224. X */
  2225. X
  2226. Xstruct Window *makewindow(screen, leftedge, topedge, width, height)
  2227. X struct Screen *screen;
  2228. X int leftedge, topedge, width, height;
  2229. X{
  2230. X  static ULONG idcmp =    CLOSEWINDOW,        /* IDCMP  Classes    */
  2231. X                        /* system flags     */
  2232. X     flags =  WINDOWCLOSE|WINDOWDEPTH|WINDOWDRAG|WINDOWSIZING|NOCAREREFRESH|SMART_REFRESH|ACTIVATE;
  2233. X
  2234. X return (struct Window *)createwindow(screen, flags, idcmp, leftedge, topedge, width, height);
  2235. X}
  2236. X
  2237. X
  2238. END_OF_FILE
  2239. if test 3360 -ne `wc -c <'src/window.c'`; then
  2240.     echo shar: \"'src/window.c'\" unpacked with wrong size!
  2241. fi
  2242. # end of 'src/window.c'
  2243. fi
  2244. echo shar: End of archive 1 \(of 2\).
  2245. cp /dev/null ark1isdone
  2246. MISSING=""
  2247. for I in 1 2 ; do
  2248.     if test ! -f ark${I}isdone ; then
  2249.     MISSING="${MISSING} ${I}"
  2250.     fi
  2251. done
  2252. if test "${MISSING}" = "" ; then
  2253.     echo You have unpacked both archives.
  2254.     rm -f ark[1-9]isdone
  2255. else
  2256.     echo You still need to unpack the following archives:
  2257.     echo "        " ${MISSING}
  2258. fi
  2259. ##  End of shell archive.
  2260. exit 0
  2261. -- 
  2262. Mail submissions (sources or binaries) to <amiga@uunet.uu.net>.
  2263. Mail comments to the moderator at <amiga-request@uunet.uu.net>.
  2264. Post requests for sources, and general discussion to comp.sys.amiga.
  2265.